Class: AccountController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- AccountController
- Includes:
- LoginSystem
- Defined in:
- app/controllers/account_controller.rb
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
4 5 6 |
# File 'app/controllers/account_controller.rb', line 4 def index redirect_to :action => "welcome" end |
#login ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/account_controller.rb', line 26 def login case request.method when :post if usr=User.authenticate(params[:user_login], params[:user_password]) session[:user_id] = usr.id flash['notice'] = usr.login "'s login successful" redirect_back_or_default :action => "welcome" else flash.now['notice'] = "Login unsuccessful" end end end |
#logout ⇒ Object
19 20 21 22 23 24 |
# File 'app/controllers/account_controller.rb', line 19 def logout session[:navList] = :logout session[:user_id] = nil redirect_back_or_default :action => "login" flash.now['notice'] = "Logout successfully" end |
#signup ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/account_controller.rb', line 8 def signup if request.post? @user = User.new(params[:user]) if @user.save session[:user_id] = User.authenticate(@user.login, params[:user][:password]).id flash['notice'] = "Signup successful" redirect_back_or_default :action => "welcome" end end end |
#welcome ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/account_controller.rb', line 40 def welcome if session[:user_id] then @user = User.find(session[:user_id]) @mailinglists = @user.mailinglists @users = User.find_all_by_domain_id @user.domain.id else redirect_back_or_default :action => "login" end end |