Allow changes to internal user when password is void
This commit is contained in:
@ -125,6 +125,11 @@ class InternalUsersController < ApplicationController
|
|||||||
def show; end
|
def show; end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
# Let's skip the password validation if the user is edited through
|
||||||
|
# the form by another user. Otherwise, the update might fail if an
|
||||||
|
# activation_token or password_reset_token is present
|
||||||
|
@user.validate_password = current_user == @user
|
||||||
|
|
||||||
update_and_respond(object: @user, params: internal_user_params)
|
update_and_respond(object: @user, params: internal_user_params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
class InternalUser < User
|
class InternalUser < User
|
||||||
authenticates_with_sorcery!
|
authenticates_with_sorcery!
|
||||||
|
|
||||||
|
attr_accessor :validate_password
|
||||||
|
|
||||||
validates :email, presence: true, uniqueness: true
|
validates :email, presence: true, uniqueness: true
|
||||||
validates :password, confirmation: true, if: :password_void?, on: :update, presence: true
|
validates :password, confirmation: true, if: -> { password_void? && validate_password? }, on: :update, presence: true
|
||||||
validates :role, inclusion: {in: ROLES}
|
validates :role, inclusion: {in: ROLES}
|
||||||
|
|
||||||
def activated?
|
def activated?
|
||||||
@ -16,6 +18,13 @@ class InternalUser < User
|
|||||||
end
|
end
|
||||||
private :password_void?
|
private :password_void?
|
||||||
|
|
||||||
|
def validate_password?
|
||||||
|
return true if @validate_password.nil?
|
||||||
|
|
||||||
|
@validate_password
|
||||||
|
end
|
||||||
|
private :validate_password?
|
||||||
|
|
||||||
def teacher?
|
def teacher?
|
||||||
role == 'teacher'
|
role == 'teacher'
|
||||||
end
|
end
|
||||||
|
@ -522,6 +522,7 @@ de:
|
|||||||
index:
|
index:
|
||||||
activate: Aktivieren
|
activate: Aktivieren
|
||||||
forgot_password: Passwort zurücksetzen
|
forgot_password: Passwort zurücksetzen
|
||||||
|
reset_password: Passwort zurücksetzen
|
||||||
activate:
|
activate:
|
||||||
headline: Registrierung abschließen
|
headline: Registrierung abschließen
|
||||||
submit: Passwort speichern
|
submit: Passwort speichern
|
||||||
|
@ -522,6 +522,7 @@ en:
|
|||||||
index:
|
index:
|
||||||
activate: Activate
|
activate: Activate
|
||||||
forgot_password: Reset Password
|
forgot_password: Reset Password
|
||||||
|
reset_password: Reset Password
|
||||||
activate:
|
activate:
|
||||||
headline: Complete Registration
|
headline: Complete Registration
|
||||||
submit: Set Password
|
submit: Set Password
|
||||||
|
Reference in New Issue
Block a user