Class: LwqzxAuth::AuthController

Inherits:
ApplicationController show all
Defined in:
app/controllers/lwqzx_auth/auth_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#check_me

Instance Method Details

#authObject



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

   = params[:login]
  psd = params[:password]
  
  hsh = lauth(,psd)
  if hsh["name"].blank?
    redirect_to  , alert: "用户信息有误"
  else
     = 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] = 
    session[:realname] = name
    session[:groups] = groups
    redirect_to main_app.root_path and return
  end
end

#loginObject



6
7
# File 'app/controllers/lwqzx_auth/auth_controller.rb', line 6

def 
end

#logoutObject



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 = cookies[:auth_token]
  unless auth_token.blank?
    one = Remember.where(token: auth_token).first
    cookies.delete(:auth_token)
    one.delete if one
  end
  reset_session
  redirect_to  main_app.root_path
end