2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/api/v5/tokens_controller.rb', line 2
def create
.merge!(authorize_response.)
if authorize_response.status == :bad_request
render json: authorize_response.body,
status: authorize_response.status
else
user = User.fetch(authorize_response.token.resource_owner_id)
Users::UpdateUserSignInTimestampsWorker.perform_async(user.id)
json = {
success: true,
data: Api::V5::UserSerializer.new(
user,
fields: %i[
id name email language r_code phone calling_code points avatar
],
).as_json.merge(authorize_response.body),
message: nil,
}
render json: json,
status: authorize_response.status
end
rescue Doorkeeper::Errors::DoorkeeperError, Doorkeeper::OAuth::ErrorResponse => e
render json: { message: e.message, success: false }
rescue StandardError => e
APMErrorHandler.report(e)
render json: { message: 'Sorry, something went wrong', success: false },
status: :internal_server_error
end
|