Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - `app/controllers/concerns/sign_in_token_authentication_concern.rb`: Conflict caused because of glitch-soc's theming system. Took upstream's new code and applied the theming system changes on top of it. - `app/controllers/concerns/two_factor_authentication_concern.rb`: Conflict caused because of glitch-soc's theming system. Took upstream's new code and applied the theming system changes on top of it.
This commit is contained in:
@ -70,12 +70,16 @@ class SessionActivation < ApplicationRecord
|
||||
end
|
||||
|
||||
def assign_access_token
|
||||
superapp = Doorkeeper::Application.find_by(superapp: true)
|
||||
self.access_token = Doorkeeper::AccessToken.create!(access_token_attributes)
|
||||
end
|
||||
|
||||
self.access_token = Doorkeeper::AccessToken.create!(application_id: superapp&.id,
|
||||
resource_owner_id: user_id,
|
||||
scopes: 'read write follow',
|
||||
expires_in: Doorkeeper.configuration.access_token_expires_in,
|
||||
use_refresh_token: Doorkeeper.configuration.refresh_token_enabled?)
|
||||
def access_token_attributes
|
||||
{
|
||||
application_id: Doorkeeper::Application.find_by(superapp: true)&.id,
|
||||
resource_owner_id: user_id,
|
||||
scopes: 'read write follow',
|
||||
expires_in: Doorkeeper.configuration.access_token_expires_in,
|
||||
use_refresh_token: Doorkeeper.configuration.refresh_token_enabled?,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -63,7 +63,7 @@ class User < ApplicationRecord
|
||||
devise :two_factor_backupable,
|
||||
otp_number_of_backup_codes: 10
|
||||
|
||||
devise :registerable, :recoverable, :rememberable, :trackable, :validatable,
|
||||
devise :registerable, :recoverable, :rememberable, :validatable,
|
||||
:confirmable
|
||||
|
||||
include Omniauthable
|
||||
@ -165,6 +165,24 @@ class User < ApplicationRecord
|
||||
prepare_new_user! if new_user && approved?
|
||||
end
|
||||
|
||||
def update_sign_in!(request, new_sign_in: false)
|
||||
old_current, new_current = current_sign_in_at, Time.now.utc
|
||||
self.last_sign_in_at = old_current || new_current
|
||||
self.current_sign_in_at = new_current
|
||||
|
||||
old_current, new_current = current_sign_in_ip, request.remote_ip
|
||||
self.last_sign_in_ip = old_current || new_current
|
||||
self.current_sign_in_ip = new_current
|
||||
|
||||
if new_sign_in
|
||||
self.sign_in_count ||= 0
|
||||
self.sign_in_count += 1
|
||||
end
|
||||
|
||||
save(validate: false) unless new_record?
|
||||
prepare_returning_user!
|
||||
end
|
||||
|
||||
def pending?
|
||||
!approved?
|
||||
end
|
||||
@ -196,11 +214,6 @@ class User < ApplicationRecord
|
||||
prepare_new_user!
|
||||
end
|
||||
|
||||
def update_tracked_fields!(request)
|
||||
super
|
||||
prepare_returning_user!
|
||||
end
|
||||
|
||||
def otp_enabled?
|
||||
otp_required_for_login
|
||||
end
|
||||
|
Reference in New Issue
Block a user