internetee-registry/app/controllers/registrar/current_user_controller.rb
Artur Beljajev 9684c8e59f Refactor Devise integration
- Use scoped users
- Use the named route helpers instead of hardcoded paths
2018-06-20 12:21:22 +03:00

18 lines
428 B
Ruby

class Registrar
class CurrentUserController < BaseController
skip_authorization_check
def switch
raise 'Cannot switch to unlinked user' unless current_registrar_user.linked_with?(new_user)
sign_in(:registrar_user, new_user)
redirect_to :back, notice: t('.switched', new_user: new_user)
end
private
def new_user
@new_user ||= ApiUser.find(params[:new_user_id])
end
end
end