From a4c892ec0a1ce4c8b48dfa1e85cbe4ed4d96814b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Tue, 25 Oct 2022 11:19:59 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20cloudIDE=20saas=E5=AE=9A=E5=88=B6api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 11 +++++++++++ app/controllers/public_keys_controller.rb | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cfff09c2e..eaffdeca0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -181,6 +181,17 @@ class ApplicationController < ActionController::Base tip_exception(401, "请登录后再操作") unless User.current.logged? end + def require_login_cloud_ide_saas + if params[:sign].present? && params[:email].present? + sign = Digest::MD5.hexdigest("#{OPENKEY}#{params[:email]}") + if params[:sign].to_s == sign + user = User.find_by(mail: params[:email]) + User.current = user + end + end + tip_exception(401, "请登录后再操作") unless User.current.logged? + end + def require_profile_completed tip_exception(411, "请完善资料后再操作") unless User.current.profile_is_completed? end diff --git a/app/controllers/public_keys_controller.rb b/app/controllers/public_keys_controller.rb index 0e18e3e09..fa6601178 100644 --- a/app/controllers/public_keys_controller.rb +++ b/app/controllers/public_keys_controller.rb @@ -1,5 +1,5 @@ class PublicKeysController < ApplicationController - before_action :require_login_or_token + before_action :require_login_cloud_ide_saas before_action :find_public_key, only: [:destroy] def index @@ -61,4 +61,6 @@ class PublicKeysController < ApplicationController def find_public_key @public_key = current_user.public_keys.find_by_id(params[:id]) end + + end \ No newline at end of file