Commit e0f1c546 by liyijie

Fix oauth relate should auth session

parent befab240
...@@ -15,7 +15,7 @@ module RailsApiAuthentication ...@@ -15,7 +15,7 @@ module RailsApiAuthentication
def acts_as_oauth_session(klass_sym) def acts_as_oauth_session(klass_sym)
include RailsApiAuthentication::AuthAction include RailsApiAuthentication::AuthAction
include RailsApiAuthentication::OauthSession include RailsApiAuthentication::OauthSession
auth_action klass_sym, only: [:destroy] auth_action klass_sym, only: [:update, :destroy]
oauth_session klass_sym oauth_session klass_sym
end end
......
...@@ -14,9 +14,9 @@ module RailsApiAuthentication ...@@ -14,9 +14,9 @@ module RailsApiAuthentication
def update def update
@auth_token = self.class.klass.oauth_relate( @auth_token = self.class.klass.oauth_relate(
session_relate_params.delete(:token), self.send("current_#{self.class.klass_sym}")&.token,
session_relate_params.delete(:oauth_type), session_params.delete(:oauth_type),
session_relate_params.delete(:oauth_id), session_params.delete(:oauth_id),
) )
render json: { token: @auth_token.token }, status: 200 render json: { token: @auth_token.token }, status: 200
rescue UserError => e rescue UserError => e
...@@ -28,12 +28,6 @@ module RailsApiAuthentication ...@@ -28,12 +28,6 @@ module RailsApiAuthentication
render json: { message: "logout successful" }, status: 200 render json: { message: "logout successful" }, status: 200
end end
def session_relate_params
params.require(self.class.klass_sym).permit(
:oauth_type, :oauth_id, :token
)
end
def session_params def session_params
params.require(self.class.klass_sym).permit(:oauth_type, :oauth_id) params.require(self.class.klass_sym).permit(:oauth_type, :oauth_id)
end 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