2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
module ChatNames
|
|
|
|
class AuthorizeUserService
|
2017-09-10 17:25:29 +05:30
|
|
|
include Gitlab::Routing
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2023-03-17 16:20:25 +05:30
|
|
|
def initialize(params)
|
2017-08-17 22:00:37 +05:30
|
|
|
@params = params
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
|
|
|
return unless chat_name_params.values.all?(&:present?)
|
|
|
|
|
|
|
|
token = request_token
|
|
|
|
|
|
|
|
new_profile_chat_name_url(token: token) if token
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def request_token
|
|
|
|
chat_name_token.store!(chat_name_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
def chat_name_token
|
2019-12-04 20:38:33 +05:30
|
|
|
@chat_name_token ||= Gitlab::ChatNameToken.new
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def chat_name_params
|
|
|
|
{
|
2022-08-27 11:52:29 +05:30
|
|
|
team_id: @params[:team_id],
|
2017-08-17 22:00:37 +05:30
|
|
|
team_domain: @params[:team_domain],
|
2022-08-27 11:52:29 +05:30
|
|
|
chat_id: @params[:user_id],
|
|
|
|
chat_name: @params[:user_name]
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|