2017-04-07 13:40:26 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicationsController
|
|
|
|
skip_before_action :authenticate_resource_owner!
|
|
|
|
|
|
|
|
before_action :store_current_location
|
|
|
|
before_action :authenticate_resource_owner!
|
2020-09-11 21:56:35 +03:00
|
|
|
before_action :require_not_suspended!, only: :destroy
|
2019-02-04 23:25:42 +02:00
|
|
|
before_action :set_body_classes
|
2023-04-19 17:07:29 +03:00
|
|
|
before_action :set_cache_headers
|
2017-04-07 13:40:26 +03:00
|
|
|
|
2023-05-22 15:03:38 +03:00
|
|
|
before_action :set_last_used_at_by_app, only: :index, unless: -> { request.format == :json }
|
|
|
|
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 11:48:50 +03:00
|
|
|
skip_before_action :require_functional!
|
|
|
|
|
2017-04-08 03:30:50 +03:00
|
|
|
include Localized
|
|
|
|
|
2018-05-19 22:05:08 +03:00
|
|
|
def destroy
|
|
|
|
Web::PushSubscription.unsubscribe_for(params[:id], current_resource_owner)
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2017-04-07 13:40:26 +03:00
|
|
|
private
|
|
|
|
|
2019-02-04 23:25:42 +02:00
|
|
|
def set_body_classes
|
|
|
|
@body_classes = 'admin'
|
|
|
|
end
|
|
|
|
|
2017-04-07 13:40:26 +03:00
|
|
|
def store_current_location
|
|
|
|
store_location_for(:user, request.url)
|
|
|
|
end
|
2020-09-11 21:56:35 +03:00
|
|
|
|
|
|
|
def require_not_suspended!
|
2023-11-30 17:43:26 +02:00
|
|
|
forbidden if current_account.unavailable?
|
2020-09-11 21:56:35 +03:00
|
|
|
end
|
2023-04-19 17:07:29 +03:00
|
|
|
|
|
|
|
def set_cache_headers
|
|
|
|
response.cache_control.replace(private: true, no_store: true)
|
|
|
|
end
|
2023-05-22 15:03:38 +03:00
|
|
|
|
|
|
|
def set_last_used_at_by_app
|
|
|
|
@last_used_at_by_app = Doorkeeper::AccessToken
|
|
|
|
.select('DISTINCT ON (application_id) application_id, last_used_at')
|
|
|
|
.where(resource_owner_id: current_resource_owner.id)
|
|
|
|
.where.not(last_used_at: nil)
|
|
|
|
.order(application_id: :desc, last_used_at: :desc)
|
|
|
|
.pluck(:application_id, :last_used_at)
|
|
|
|
.to_h
|
|
|
|
end
|
2017-04-07 13:40:26 +03:00
|
|
|
end
|