X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c8f9387420233bd7e845cb205c3b68ede1f90024..b95e9d27599ee55b2fd61a444acc3264c7637265:/app/controllers/user_controller.rb diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 3012765d2..d61455bf1 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -14,7 +14,38 @@ class UserController < ApplicationController end def new + render :layout => 'site' + end + + def login + if params[:user] + email = params[:user][:email] + pass = params[:user][:password] + u = User.authenticate(email, pass) + if u + u.token = User.make_token + u.timeout = 1.day.from_now + u.save + session[:token] = u.token + redirect_to :controller => 'site', :action => 'index' + return + end + end + + render :layout => 'site' + end + def logout + if session[:token] + u = User.find_by_token(session[:token]) + if u + u.token = User.make_token + u.timeout = Time.now + u.save + end + end + session[:token] = nil + redirect_to :controller => 'site', :action => 'index' end def confirm @@ -23,6 +54,9 @@ class UserController < ApplicationController @user.active = true @user.save flash[:notice] = 'Confirmed your account' + + #FIXME: login the person magically + redirect_to :action => 'login' else flash[:notice] = 'Something went wrong confirming that user'