Class: WebSandboxConsole::AuthorizationController

Inherits:
ApplicationController show all
Defined in:
app/controllers/web_sandbox_console/authorization_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#restrict_ip

Instance Method Details

#authObject

授权



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/web_sandbox_console/authorization_controller.rb', line 16

def auth
  if params[:secret_text].blank?
    flash[:notice] = '密文为空'
    return redirect_to root_path
  end

  if public_key.blank?
    flash[:notice] = '公钥未配置'
    return redirect_to root_path
  end

  result_hash = decrypt_secret_text(params[:secret_text])
  token       = result_hash[:content]
  if result_hash[:success] && fetch_cache_token(token)
    flash[:notice] = "授权成功"
    session[:pass_auth] = true
  else
    flash[:notice] = "授权失败:#{result_hash[:content]}"
  end

  redirect_to root_path
end

#fetch_tokenObject

获取令牌



8
9
10
11
12
13
# File 'app/controllers/web_sandbox_console/authorization_controller.rb', line 8

def fetch_token
  @token = SecureRandom.uuid
  save_cache_token(@token)
  flash[:notice] = "令牌: #{@token},此令牌先保存,后续使用。"
  redirect_to auth_page_path
end