lib/devise/api/controllers/helpers.rb in devise-api-0.1.2 vs lib/devise/api/controllers/helpers.rb in devise-api-0.1.3
- old
+ new
@@ -36,28 +36,25 @@
Devise.api.config.base_token_model.constantize.find_by(refresh_token: token)
end
def current_devise_api_token
- token = find_devise_api_token
+ return @current_devise_api_token if @current_devise_api_token
+ token = find_devise_api_token
devise_api_token_model = Devise.api.config.base_token_model.constantize
-
- if Devise.api.config.refresh_token.enabled
- return devise_api_token_model
- .where(access_token: token)
- .or(devise_api_token_model.where(refresh_token: token))
- &.first
- end
-
- devise_api_token_model.find_by(access_token: token)
+ @current_devise_api_token = devise_api_token_model.find_by(access_token: token)
end
def current_devise_api_user
current_devise_api_token&.resource_owner
end
private
+
+ def resource_class
+ current_devise_api_user&.class
+ end
def extract_devise_api_token_from_params
params[Devise.api.config.authorization.params_key]
end