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 raise "Not Implemented!"
34 @user = User.new(params[:user])
35 return unless request.post?
37 self.current_user = @user
38 redirect_back_or_default(:controller => '/site', :action => 'index')
39 flash[:notice] = "Thanks for signing up!"
40 rescue ActiveRecord::RecordInvalid
41 render :action => 'signup'
45 self.current_user.forget_me if logged_in?
46 cookies.delete :auth_token
48 flash[:notice] = "You have been logged out."
49 redirect_back_or_default(:controller => '/site', :action => 'index')
51 #======================================================================
53 #The following methods are for slectricity specific uses
55 @user = User.find(params[:id])