+ 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], :conditions => {:visible => true})
+
+ if user
+ token = user.tokens.create
+ Notifier.deliver_lost_password(user, token)
+ @notice = "Sorry you lost it :-( but an email is on its way so you can reset it soon."
+ else
+ @notice = "Couldn't find that email address, sorry."
+ end
+ end
+ end
+
+ def reset_password
+ @title = 'reset password'
+ if params['token']
+ token = UserToken.find_by_token(params[:token])
+ if token
+ pass = OSM::make_token(8)
+ user = token.user
+ user.pass_crypt = pass
+ user.pass_crypt_confirmation = pass
+ user.active = true
+ user.email_valid = true
+ user.save!
+ token.destroy
+ Notifier.deliver_reset_password(user, pass)
+ flash[:notice] = "Your password has been changed and is on its way to your mailbox :-)"
+ else
+ flash[:notice] = "Didn't find that token, check the URL maybe?"
+ end
+ end
+
+ redirect_to :action => 'login'
+ end
+