Commit e0f1c546 by liyijie

Fix oauth relate should auth session

parent befab240
......@@ -15,7 +15,7 @@ module RailsApiAuthentication
def acts_as_oauth_session(klass_sym)
include RailsApiAuthentication::AuthAction
include RailsApiAuthentication::OauthSession
auth_action klass_sym, only: [:destroy]
auth_action klass_sym, only: [:update, :destroy]
oauth_session klass_sym
end
......
......@@ -14,9 +14,9 @@ module RailsApiAuthentication
def update
@auth_token = self.class.klass.oauth_relate(
session_relate_params.delete(:token),
session_relate_params.delete(:oauth_type),
session_relate_params.delete(:oauth_id),
self.send("current_#{self.class.klass_sym}")&.token,
session_params.delete(:oauth_type),
session_params.delete(:oauth_id),
)
render json: { token: @auth_token.token }, status: 200
rescue UserError => e
......@@ -28,12 +28,6 @@ module RailsApiAuthentication
render json: { message: "logout successful" }, status: 200
end
def session_relate_params
params.require(self.class.klass_sym).permit(
:oauth_type, :oauth_id, :token
)
end
def session_params
params.require(self.class.klass_sym).permit(:oauth_type, :oauth_id)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment