1 class UserController < ApplicationController
4 before_filter :authorize, :only => :preferences
5 before_filter :authorize_web, :only => :rename
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 new_name = params['display_name']
24 @user.display_name = new_name
26 flash[:notice] = "User display name updated OK."
28 flash[:notice] = "Rename failed: #{ @user.errors.full_messages.join('; ') }."
31 flash[:notice] = 'not logged in'
37 if params['user']['email']
38 user = User.find_by_email(params['user']['email'])
40 user.token = User.make_token
42 Notifier::deliver_lost_password(user)
43 flash[:notice] = "Sorry you lost it :-( but an email is on it's way so you can reset it soon."
45 flash[:notice] = "Couldn't find that email address, sorry."
52 user = User.find_by_token(params['token'])
54 pass = User.make_token(8)
55 user.pass_crypt = pass
57 Notifier::deliver_reset_password(user, pass)
58 flash[:notice] = "You're password has been changed and is on the way to your mailbox :-)"
60 flash[:notice] = "Didn't find that token, check the URL maybe?"
63 redirect_to :action => 'login'
71 email = params[:user][:email]
72 pass = params[:user][:password]
73 u = User.authenticate(email, pass)
75 u.token = User.make_token
76 u.timeout = 1.day.from_now
78 session[:token] = u.token
79 redirect_to :controller => 'site', :action => 'index'
82 flash[:notice] = "Couldn't log in with those details"
89 u = User.find_by_token(session[:token])
91 u.token = User.make_token
97 redirect_to :controller => 'site', :action => 'index'
101 @user = User.find_by_token(params[:confirm_string])
102 if @user && @user.active == 0
105 flash[:notice] = 'Confirmed your account, thanks for signing up!'
107 #FIXME: login the person magically
109 redirect_to :action => 'login'
111 flash[:notice] = 'Something went wrong confirming that user'
117 render_text @user.preferences
118 elsif request.post? or request.put?
119 @user.preferences = request.raw_post
121 render :nothing => true
123 render :status => 400, :nothing => true