Switch web site to use OAuth 2

This commit is contained in:
Tom Hughes 2021-06-27 18:42:47 +01:00
parent 90360df6d7
commit b4a1e41968
7 changed files with 20 additions and 42 deletions

View file

@ -288,11 +288,23 @@ class User < ApplicationRecord
end
##
# return an oauth access token for a specified application
# return an oauth 1 access token for a specified application
def access_token(application_key)
ClientApplication.find_by(:key => application_key).access_token_for_user(self)
end
##
# return an oauth 2 access token for a specified application
def oauth_token(application_id)
application = Doorkeeper.config.application_model.find_by(:uid => application_id)
Doorkeeper.config.access_token_model.find_or_create_for(
:application => application,
:resource_owner => self,
:scopes => application.scopes
)
end
def fingerprint
digest = Digest::SHA256.new
digest.update(email)