1 class UserController < ApplicationController
4 before_filter :authorize, :only => :preferences
5 before_filter :authorize_web, :only => [:rename, :account, :go_public]
6 before_filter :require_user, :only => [:rename, :account, :go_public]
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 @user.data_public = true
34 flash[:notice] = 'All your edits are now public'
35 redirect_to :controller => 'user', :action => 'account'
39 if params['user']['email']
40 user = User.find_by_email(params['user']['email'])
42 user.token = User.make_token
44 Notifier::deliver_lost_password(user)
45 flash[:notice] = "Sorry you lost it :-( but an email is on it's way so you can reset it soon."
47 flash[:notice] = "Couldn't find that email address, sorry."
54 user = User.find_by_token(params['token'])
56 pass = User.make_token(8)
57 user.pass_crypt = pass
59 Notifier::deliver_reset_password(user, pass)
60 flash[:notice] = "You're password has been changed and is on the way to your mailbox :-)"
62 flash[:notice] = "Didn't find that token, check the URL maybe?"
65 redirect_to :action => 'login'
73 email = params[:user][:email]
74 pass = params[:user][:password]
75 u = User.authenticate(email, pass)
77 u.token = User.make_token
78 u.timeout = 1.day.from_now
80 session[:token] = u.token
81 redirect_to :controller => 'site', :action => 'index'
84 flash[:notice] = "Couldn't log in with those details"
91 u = User.find_by_token(session[:token])
93 u.token = User.make_token
99 redirect_to :controller => 'site', :action => 'index'
103 @user = User.find_by_token(params[:confirm_string])
104 if @user && @user.active == 0
107 flash[:notice] = 'Confirmed your account, thanks for signing up!'
109 #FIXME: login the person magically
111 redirect_to :action => 'login'
113 flash[:notice] = 'Something went wrong confirming that user'
119 render_text @user.preferences
120 elsif request.post? or request.put?
121 @user.preferences = request.raw_post
123 render :nothing => true
125 render :status => 400, :nothing => true