新增:acge 第三方登录回调地址
This commit is contained in:
parent
d78bd895d1
commit
e891d52c32
|
@ -0,0 +1,32 @@
|
||||||
|
class Oauth::AcgeController < Oauth::BaseController
|
||||||
|
include RegisterHelper
|
||||||
|
|
||||||
|
def create
|
||||||
|
begin
|
||||||
|
code = params['code'].to_s.strip
|
||||||
|
tip_exception("code不能为空") if code.blank?
|
||||||
|
uid = params['uid'].to_s.strip
|
||||||
|
tip_exception("uid不能为空") if uid.blank?
|
||||||
|
redirect_uri = params['redirect_uri'].to_s.strip
|
||||||
|
tip_exception("redirect_uri不能为空") if redirect_uri.blank?
|
||||||
|
|
||||||
|
open_user = OpenUsers::Acge.find_by(uid: uid)
|
||||||
|
if open_user.present? && open_user.user.present?
|
||||||
|
successful_authentication(open_user.user)
|
||||||
|
redirect_to redirect_uri
|
||||||
|
return
|
||||||
|
else
|
||||||
|
if current_user.blank? || !current_user.logged?
|
||||||
|
session[:unionid] = uid
|
||||||
|
else
|
||||||
|
OpenUsers::Acge.create!(user: current_user, uid: uid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Rails.logger.info("[OAuth2] session[:unionid] -> #{session[:unionid]}")
|
||||||
|
redirect_to "/bindlogin/acge?redirect_uri=#{redirect_uri}"
|
||||||
|
rescue Exception => ex
|
||||||
|
render_error(ex.message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,27 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: open_users
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# user_id :integer
|
||||||
|
# type :string(255)
|
||||||
|
# uid :string(255)
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# extra :text(65535)
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_open_users_on_type_and_uid (type,uid) UNIQUE
|
||||||
|
# index_open_users_on_user_id (user_id)
|
||||||
|
#
|
||||||
|
|
||||||
|
class OpenUsers::Acge < OpenUser
|
||||||
|
def nickname
|
||||||
|
extra&.[]('nickname')
|
||||||
|
end
|
||||||
|
|
||||||
|
def en_type
|
||||||
|
'acge'
|
||||||
|
end
|
||||||
|
end
|
|
@ -24,6 +24,7 @@ Rails.application.routes.draw do
|
||||||
# get 'auth/qq/callback', to: 'oauth/qq#create'
|
# get 'auth/qq/callback', to: 'oauth/qq#create'
|
||||||
get 'auth/failure', to: 'oauth/base#auth_failure'
|
get 'auth/failure', to: 'oauth/base#auth_failure'
|
||||||
get 'auth/cas/callback', to: 'oauth/cas#create'
|
get 'auth/cas/callback', to: 'oauth/cas#create'
|
||||||
|
get 'auth/acge/callback', to: "oauth/acge#create"
|
||||||
get 'auth/:provider/callback', to: 'oauth/callbacks#create'
|
get 'auth/:provider/callback', to: 'oauth/callbacks#create'
|
||||||
|
|
||||||
get 'oauth/bind', to: 'oauth/educoder#bind'
|
get 'oauth/bind', to: 'oauth/educoder#bind'
|
||||||
|
|
Loading…
Reference in New Issue