+ end
+
+ def account
+ @title = 'edit 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
+ @user.home_lon = home_lon
+ if @user.save
+ flash[:notice] = "User information updated successfully."
+ else
+ flash.delete(:notice)
+ end
+ end
+ end
+
+ def set_home
+ if params[:user][:home_lat] and params[:user][:home_lon]
+ @user.home_lat = params[:user][:home_lat].to_f
+ @user.home_lon = params[:user][:home_lon].to_f
+ if @user.save
+ flash[:notice] = "Home location saved successfully."
+ redirect_to :controller => 'user', :action => 'account'
+ end
+ end
+ end
+
+ def go_public
+ @user.data_public = true
+ @user.save
+ flash[:notice] = 'All your edits are now public.'
+ redirect_to :controller => 'user', :action => 'account', :display_name => @user.display_name
+ end
+
+ def lost_password
+ @title = 'lost password'
+ if params[:user] and params[:user][:email]
+ user = User.find_by_email(params[:user][:email])
+ if user
+ token = user.tokens.create
+ Notifier::deliver_lost_password(user, token)
+ flash[:notice] = "Sorry you lost it :-( but an email is on its way so you can reset it soon."
+ else
+ flash[:notice] = "Couldn't find that email address, sorry."
+ end
+ else
+ render :action => 'lost_password'
+ end
+ end