mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 05:26:17 +02:00
Moved switch user method to accounts
This commit is contained in:
parent
6c9fb2b025
commit
de5872fb40
5 changed files with 26 additions and 23 deletions
|
@ -73,6 +73,22 @@ module Repp
|
|||
message: I18n.t('registrar.settings.balance_auto_reload.destroy.disabled'))
|
||||
end
|
||||
|
||||
api :put, '/repp/v1/accounts/switch_user'
|
||||
desc 'Switch user to another api user'
|
||||
def switch_user
|
||||
new_user = ApiUser.find(account_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
|
||||
|
||||
api :get, '/repp/v1/accounts/balance'
|
||||
desc "Get account's balance"
|
||||
def balance
|
||||
|
@ -90,7 +106,7 @@ module Repp
|
|||
private
|
||||
|
||||
def account_params
|
||||
params.require(:account).permit(:billing_email, :iban)
|
||||
params.require(:account).permit(:billing_email, :iban, :new_user_id)
|
||||
end
|
||||
|
||||
def index_params
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue