1 class UserController < ApplicationController
4 before_filter :authorize, :only => :preferences
7 @user = User.new(params[:user])
11 flash[:notice] = 'User was successfully created. Check your email for a confirmation note, and you\'ll be mapping in no time :-)'
12 Notifier::deliver_signup_confirm(@user)
13 redirect_to :action => 'login'
15 render :action => 'new'
20 if params['user']['email']
21 user = User.find_by_email(params['user']['email'])
23 user.token = User.make_token
25 Notifier::deliver_lost_password(user)
26 flash[:notice] = "Sorry you lost it :-( but an email is on it's way so you can reset it soon."
28 flash[:notice] = "Couldn't find that email address, sorry."
35 user = User.find_by_token(params['token'])
37 pass = User.make_token(8)
38 user.pass_crypt = pass
40 Notifier::deliver_reset_password(user, pass)
41 flash[:notice] = "You're password has been changed and is on the way to your mailbox :-)"
43 flash[:notice] = "Didn't find that token, check the URL maybe?"
46 redirect_to :action => 'login'
54 email = params[:user][:email]
55 pass = params[:user][:password]
56 u = User.authenticate(email, pass)
58 u.token = User.make_token
59 u.timeout = 1.day.from_now
61 session[:token] = u.token
62 redirect_to :controller => 'site', :action => 'index'
65 flash[:notice] = "Couldn't log in with those details"
72 u = User.find_by_token(session[:token])
74 u.token = User.make_token
80 redirect_to :controller => 'site', :action => 'index'
84 @user = User.find_by_token(params[:confirm_string])
85 if @user && @user.active == 0
88 flash[:notice] = 'Confirmed your account, thanks for signing up!'
90 #FIXME: login the person magically
92 redirect_to :action => 'login'
94 flash[:notice] = 'Something went wrong confirming that user'
100 render_text @user.preferences
101 elsif request.post? or request.put?
102 @user.preferences = request.raw_post
104 render :nothing => true
106 render :status => 400, :nothing => true