2018-07-16 12:31:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-13 14:35:47 -05:00
|
|
|
module ChatNames
|
2016-11-16 08:56:30 -05:00
|
|
|
class AuthorizeUserService
|
2017-07-07 11:43:37 -04:00
|
|
|
include Gitlab::Routing
|
2016-11-13 14:35:47 -05:00
|
|
|
|
|
|
|
def initialize(service, params)
|
|
|
|
@service = service
|
|
|
|
@params = params
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2016-11-16 08:56:30 -05:00
|
|
|
return unless chat_name_params.values.all?(&:present?)
|
|
|
|
|
|
|
|
token = request_token
|
2016-11-13 14:35:47 -05:00
|
|
|
|
|
|
|
new_profile_chat_name_url(token: token) if token
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-11-16 08:56:30 -05:00
|
|
|
def request_token
|
|
|
|
chat_name_token.store!(chat_name_params)
|
|
|
|
end
|
|
|
|
|
2016-11-13 14:35:47 -05:00
|
|
|
def chat_name_token
|
2019-08-30 00:43:16 -04:00
|
|
|
@chat_name_token ||= Gitlab::ChatNameToken.new
|
2016-11-13 14:35:47 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def chat_name_params
|
|
|
|
{
|
2019-08-30 00:43:16 -04:00
|
|
|
service_id: @service.id,
|
|
|
|
team_id: @params[:team_id],
|
2016-11-13 14:35:47 -05:00
|
|
|
team_domain: @params[:team_domain],
|
2019-08-30 00:43:16 -04:00
|
|
|
chat_id: @params[:user_id],
|
|
|
|
chat_name: @params[:user_name]
|
2016-11-13 14:35:47 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|