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 #===================================================================
18 return unless request.post?
19 self.current_user = User.authenticate(params[:login], params[:password])
21 if params[:remember_me] == "1"
22 self.current_user.remember_me
23 cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }
25 redirect_back_or_default :controller => 'front'
26 flash[:notice] = "Logged in successfully"
31 raise "Not Implemented!"
35 @user = User.new(params[:user])
36 return unless request.post?
38 self.current_user = @user
39 redirect_back_or_default :controller => 'front'
40 flash[:notice] = "Thanks for signing up!"
41 rescue ActiveRecord::RecordInvalid
42 render :action => 'signup'
46 self.current_user.forget_me if logged_in?
47 cookies.delete :auth_token
49 flash[:notice] = "You have been logged out."
50 redirect_back_or_default :controller => 'front'
52 #======================================================================
54 #The following methods are for slectricity specific uses
56 @user = User.find(params[:id])