fixed oauth2.0

This commit is contained in:
“xxq250” 2022-09-28 10:22:11 +08:00
parent d401634af3
commit 095e1c7b7b
1 changed files with 8 additions and 8 deletions

View File

@ -11,7 +11,7 @@ Doorkeeper.configure do
# raise "Please configure doorkeeper resource_owner_authenticator block located in #{__FILE__}"
# Put your resource owner authentication logic here.
# Example implementation:
User.find_by(id: session[:www_user_id]) || redirect_to(new_user_session_url)
User.find_by(login: params[:auth]) || redirect_to("/oauth2?call_url=#{request.fullpath}")
end
resource_owner_from_credentials do |routes|
@ -243,8 +243,8 @@ Doorkeeper.configure do
# For more information go to
# https://doorkeeper.gitbook.io/guides/ruby-on-rails/scopes
#
# default_scopes :public
# optional_scopes :write, :update
default_scopes :public
optional_scopes :write, :update
# Allows to restrict only certain scopes for grant_type.
# By default, all the scopes will be available for all the grant types.
@ -514,19 +514,19 @@ Doorkeeper::JWT.configure do
# about the user. Defaults to a randomly generated token in a hash:
# { token: "RANDOM-TOKEN" }
token_payload do |opts|
user = User.find(opts[:resource_owner_id])
user = User.find_by(id: opts[:resource_owner_id])
{
iss: 'My App',
iss: 'Osredm',
iat: Time.current.utc.to_i,
# @see JWT reserved claims - https://tools.ietf.org/html/draft-jones-json-web-token-07#page-7
jti: SecureRandom.uuid,
user: {
id: user.id,
login: user.login,
mail: user.mail
id: user&.id,
login: user&.login,
mail: user&.mail
}
}
end