1 class AccountController < ApplicationController
4 # Be sure to include AuthenticationSystem in Application Controller instead
5 include AuthenticatedSystem
6 # If you want "remember me" functionality, add this before_filter to Application Controller
7 before_filter :login_from_cookie
9 # say something nice, you goof! something sweet.
11 redirect_to(:action => 'signup') unless logged_in? || User.count > 0
15 return unless request.post?
16 self.current_user = User.authenticate(params[:login], params[:password])
18 if params[:remember_me] == "1"
19 self.current_user.remember_me
20 cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }
22 redirect_back_or_default(:controller => '/site', :action => 'index')
23 flash[:notice] = "Logged in successfully"
28 @user = User.new(params[:user])
29 return unless request.post?
31 self.current_user = @user
32 redirect_back_or_default(:controller => '/site', :action => 'index')
33 flash[:notice] = "Thanks for signing up!"
34 rescue ActiveRecord::RecordInvalid
35 render :action => 'signup'
39 self.current_user.forget_me if logged_in?
40 cookies.delete :auth_token
42 flash[:notice] = "You have been logged out."
43 redirect_back_or_default(:controller => '/site', :action => 'index')