Class: LwqzxAuth::AuthController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- LwqzxAuth::AuthController
- Defined in:
- app/controllers/lwqzx_auth/auth_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#auth ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/lwqzx_auth/auth_controller.rb', line 22 def auth #unless verify_rucaptcha? # flash[:alert] = "验证码出错" # redirect_to main_app.root_path and return #end login = params[:login] psd = params[:password] hsh = lauth(login,psd) if hsh["name"].blank? redirect_to login_path , alert: "用户信息有误" else login = hsh["login"] name = hsh["name"] groups = hsh["user_group"] #rememberme = params[:rememberme] #if rememberme == "yes" # token = SecureRandom.urlsafe_base64 # cookies.signed[:auth_token] = token # Remember.create(token: token, login: login, name: name, groups: groups,expired: 7.days.from_now.to_i) #else # auth_token = cookies[:auth_token] # cookies.delete(:auth_token) # Remember.where(token: auth_token).delete #end session[:login] = login session[:realname] = name session[:groups] = groups redirect_to main_app.root_path and return end end |
#login ⇒ Object
6 7 |
# File 'app/controllers/lwqzx_auth/auth_controller.rb', line 6 def login end |
#logout ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/lwqzx_auth/auth_controller.rb', line 9 def logout flash[:notice]="你已经登出" auth_token = [:auth_token] unless auth_token.blank? one = Remember.where(token: auth_token).first .delete(:auth_token) one.delete if one end reset_session redirect_to main_app.root_path end |