1 class UserController < ApplicationController
4 before_filter :authorize, :only => [:preferences, :api_details, :api_gpx_files]
5 before_filter :authorize_web, :only => [:edit, :account, :go_public, :view, :diary]
6 before_filter :require_user, :only => [:edit, :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] and params[:user][:description]
23 @user.display_name = params[:user][:display_name]
24 @user.description = params[:user][:description]
26 flash[:notice] = "User edited OK."
27 redirect_to :controller => 'user', :action => 'account'
33 @user.data_public = true
35 flash[:notice] = 'All your edits are now public'
36 redirect_to :controller => 'user', :action => 'account'
40 if params['user']['email']
41 user = User.find_by_email(params['user']['email'])
43 user.token = User.make_token
45 Notifier::deliver_lost_password(user)
46 flash[:notice] = "Sorry you lost it :-( but an email is on it's way so you can reset it soon."
48 flash[:notice] = "Couldn't find that email address, sorry."
55 user = User.find_by_token(params['token'])
57 pass = User.make_token(8)
58 user.pass_crypt = pass
60 Notifier::deliver_reset_password(user, pass)
61 flash[:notice] = "You're password has been changed and is on the way to your mailbox :-)"
63 flash[:notice] = "Didn't find that token, check the URL maybe?"
66 redirect_to :action => 'login'
74 email = params[:user][:email]
75 pass = params[:user][:password]
76 u = User.authenticate(email, pass)
78 u.token = User.make_token
79 u.timeout = 1.day.from_now
81 session[:token] = u.token
82 redirect_to :controller => 'site', :action => 'index'
85 flash[:notice] = "Couldn't log in with those details"
92 u = User.find_by_token(session[:token])
94 u.token = User.make_token
100 redirect_to :controller => 'site', :action => 'index'
104 @user = User.find_by_token(params[:confirm_string])
105 if @user && @user.active == 0
108 flash[:notice] = 'Confirmed your account, thanks for signing up!'
110 #FIXME: login the person magically
112 redirect_to :action => 'login'
114 flash[:notice] = 'Something went wrong confirming that user'
120 render_text @user.preferences
121 elsif request.post? or request.put?
122 @user.preferences = request.raw_post
124 render :nothing => true
126 render :status => 400, :nothing => true
131 render :text => @user.to_xml.to_s
135 doc = OSM::API.new.get_xml_doc
136 @user.traces.each do |trace|
137 doc.root << trace.to_xml_node() if trace.public? or trace.user == @user
139 render :text => doc.to_s
143 @this_user = User.find_by_display_name(params[:display_name])
147 @this_user = User.find_by_display_name(params[:display_name])