Class: AuthController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- AuthController
- Defined in:
- app/controllers/auth_controller.rb
Instance Method Summary collapse
Instance Method Details
#login ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/auth_controller.rb', line 4 def login if request.post? if u=User.auth(params[:login],params[:password]) session[:slast_lip]=u.last_lip session[:slast_ltime]=u.last_ltime u.update_attributes(:last_lip=>request.remote_ip,:last_ltime=>Time.now) session[:slname]=params[:login] redirect_to root_path else flash[:error]="登录失败!" redirect_to login_path end end end |
#logout ⇒ Object
18 19 20 21 22 |
# File 'app/controllers/auth_controller.rb', line 18 def logout session[:slname]=nil flash[:notice]="注销成功。" redirect_to root_path end |