1 class UserController < ApplicationController
4 before_filter :authorize, :only => :preferences
5 before_filter :authorize_web, :only => [:rename, :account]
6 before_filter :require_user, :only => [:account, :display_name_edit]
9 @user = User.new(params[:user])
13 flash[:notice] = 'User was successfully created. Check your email for a confirmation note, and you\'ll be mapping in no time :-)'
14 Notifier::deliver_signup_confirm(@user)
15 redirect_to :action => 'login'
17 render :action => 'new'
22 if params[:user] and params[:user][:display_name]
23 @user.display_name = params[:user][:display_name]
25 flash[:notice] = "User display name updated OK."
26 redirect_to :controller => 'user', :action => 'account'
32 if params['user']['email']
33 user = User.find_by_email(params['user']['email'])
35 user.token = User.make_token
37 Notifier::deliver_lost_password(user)
38 flash[:notice] = "Sorry you lost it :-( but an email is on it's way so you can reset it soon."
40 flash[:notice] = "Couldn't find that email address, sorry."
47 user = User.find_by_token(params['token'])
49 pass = User.make_token(8)
50 user.pass_crypt = pass
52 Notifier::deliver_reset_password(user, pass)
53 flash[:notice] = "You're password has been changed and is on the way to your mailbox :-)"
55 flash[:notice] = "Didn't find that token, check the URL maybe?"
58 redirect_to :action => 'login'
66 email = params[:user][:email]
67 pass = params[:user][:password]
68 u = User.authenticate(email, pass)
70 u.token = User.make_token
71 u.timeout = 1.day.from_now
73 session[:token] = u.token
74 redirect_to :controller => 'site', :action => 'index'
77 flash[:notice] = "Couldn't log in with those details"
84 u = User.find_by_token(session[:token])
86 u.token = User.make_token
92 redirect_to :controller => 'site', :action => 'index'
96 @user = User.find_by_token(params[:confirm_string])
97 if @user && @user.active == 0
100 flash[:notice] = 'Confirmed your account, thanks for signing up!'
102 #FIXME: login the person magically
104 redirect_to :action => 'login'
106 flash[:notice] = 'Something went wrong confirming that user'
112 render_text @user.preferences
113 elsif request.post? or request.put?
114 @user.preferences = request.raw_post
116 render :nothing => true
118 render :status => 400, :nothing => true