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
14 #these methods provide basic functionality for the user login system
15 #===================================================================
17 return unless request.post?
18 self.current_user = User.authenticate(params[:login], params[:password])
20 if params[:remember_me] == "1"
21 self.current_user.remember_me
22 cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }
24 redirect_back_or_default(:controller => '/site', :action => 'index')
25 flash[:notice] = "Logged in successfully"
30 @user = User.new(params[:user])
31 return unless request.post?
33 self.current_user = @user
34 redirect_back_or_default(:controller => '/site', :action => 'index')
35 flash[:notice] = "Thanks for signing up!"
36 rescue ActiveRecord::RecordInvalid
37 render :action => 'signup'
41 self.current_user.forget_me if logged_in?
42 cookies.delete :auth_token
44 flash[:notice] = "You have been logged out."
45 redirect_back_or_default(:controller => '/site', :action => 'index')
47 #======================================================================
49 #The following methods are for slectricity specific uses
51 @user = User.find(params[:id])