Class: WebSandboxConsole::AuthorizationController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- WebSandboxConsole::AuthorizationController
- Defined in:
- app/controllers/web_sandbox_console/authorization_controller.rb
Instance Method Summary collapse
-
#auth ⇒ Object
授权.
-
#fetch_token ⇒ Object
获取令牌.
Methods inherited from ApplicationController
Instance Method Details
#auth ⇒ Object
授权
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_token ⇒ Object
获取令牌
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 |