Moved switch user method to accounts

This commit is contained in:
Sergei Tsõganov 2022-06-15 12:56:54 +03:00
parent 6c9fb2b025
commit de5872fb40
5 changed files with 26 additions and 23 deletions

View file

@ -23,22 +23,6 @@ module Repp
render_success(data: { token: token, username: user.username })
end
api :put, '/repp/v1/registrar/auth/switch_user'
desc 'Switch session to another api user'
def switch_user
new_user = ApiUser.find(auth_params[:new_user_id])
unless current_user.linked_with?(new_user)
handle_non_epp_errors(new_user, 'Cannot switch to unlinked user')
return
end
@current_user = new_user
data = auth_values_to_data(registrar: current_user.registrar)
message = I18n.t('registrar.current_user.switch.switched', new_user: new_user)
token = Base64.urlsafe_encode64("#{new_user.username}:#{new_user.plain_text_password}")
render_success(data: { token: token, registrar: data }, message: message)
end
private
def auth_params