of the separate edit page that (partially) duplicated the account page.
layout 'site'
before_filter :authorize, :only => [:preferences, :api_details, :api_gpx_files]
- before_filter :authorize_web, :only => [:edit, :account, :go_public, :view, :diary, :make_friend]
- before_filter :require_user, :only => [:edit, :set_home, :account, :go_public, :make_friend]
+ before_filter :authorize_web, :only => [:account, :go_public, :view, :diary, :make_friend]
+ before_filter :require_user, :only => [:set_home, :account, :go_public, :make_friend]
def save
@user = User.new(params[:user])
end
end
- def edit
+ def account
if params[:user] and params[:user][:display_name] and params[:user][:description]
home_lat = params[:user][:home_lat]
home_lon = params[:user][:home_lon]
@user.display_name = params[:user][:display_name]
+ if params[:user][:pass_crypt].length > 0 or params[:user][:pass_crypt_confirmation].length > 0
+ @user.pass_crypt = params[:user][:pass_crypt]
+ @user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation]
+ end
@user.description = params[:user][:description]
@user.home_lat = home_lat.to_f
@user.home_lon = home_lon.to_f
if @user.save
flash[:notice] = "User information updated successfully."
- redirect_to :controller => 'user', :action => 'account'
+ else
+ flash.delete(:notice)
end
end
end
end
def encrypt_password
- self.pass_crypt = Digest::MD5.hexdigest(pass_crypt) if pass_crypt_confirmation
+ self.pass_crypt = Digest::MD5.hexdigest(pass_crypt) unless pass_crypt_confirmation.nil?
end
def self.authenticate(email, passwd)
<h2>User details</h2>
<%= error_messages_for 'user' %>
-<% form_tag :controller => 'user', :action => 'edit', :display_name => @user.display_name do %>
+<% form_tag :controller => 'user', :action => 'account', :display_name => @user.display_name do %>
<table style="width : 100%">
<tr><td>Name</td><td><%= @user.email %></td></tr>
<tr><td>Mapper since</td><td><%= @user.creation_time %> (<%= time_ago_in_words(@user.creation_time) %> ago)</td></tr>
<tr><td>Display Name</td><td><%= text_field :user, :display_name, :value => @user.display_name %></td></tr>
+ <tr><td>Password</td><td><%= password_field('user', 'pass_crypt',{:value => '', :size => 50, :maxlength => 255}) %></td></tr>
+ <tr><td>Confirm Password</td><td><%= password_field('user', 'pass_crypt_confirmation',{:value => '', :size => 50, :maxlength => 255}) %></td></tr>
<tr id="homerow" <% unless @user.home_lat and @user.home_lon %> class="nohome" <%end%> ><td>Your home</td><td><em class="message">You have not entered your home location.</em><span class="location">Latitude: <%= text_field :user, :home_lat, :value => @user.home_lat, :size => 20, :id => "home_lat" %> Longitude <%= text_field :user, :home_lon, :value => @user.home_lon, :size => 20, :id => "home_lon" %></span> </td></tr>
<tr><td></td><td>
+++ /dev/null
-<h2>Edit details:</h2>
-<%= error_messages_for 'user' %>
-<% form_tag :controller => 'user', :action => 'edit', :display_name => User.find(@user.id).display_name do %>
-<table>
- <tr><td>display name</td><td><%= text_field :user, :display_name, :value => @user.display_name %></td></tr>
- <tr><td valign="top">description</td><td><%= text_area :user, :description, :value => @user.description %></td></tr>
- <tr><td>home latitude</td><td><%= text_field :user, :home_lat, :value => @user.home_lat %></td>
- <tr><td>home longitude</td><td><%= text_field :user, :home_lon, :value => @user.home_lon %></td>
-
-</table>
-<%= submit_tag 'Change' %>
-<% end %>
map.connect '/user/:display_name/diary', :controller => 'user', :action => 'diary'
map.connect '/user/:display_name/diary/rss', :controller => 'user', :action => 'rss'
map.connect '/user/:display_name/diary/newpost', :controller => 'diary_entry', :action => 'new'
- map.connect '/user/:display_name/edit', :controller => 'user', :action => 'edit'
map.connect '/user/:display_name/account', :controller => 'user', :action => 'account'
map.connect '/user/:display_name/set_home', :controller => 'user', :action => 'set_home'
map.connect '/diary', :controller => 'diary_entry', :action => 'list'