forked from OpenNeo/impress
Don't require current_password
for settings if user doesn't have one
This commit is contained in:
parent
0f5bb2a861
commit
f6d3992045
2 changed files with 18 additions and 9 deletions
|
@ -24,7 +24,13 @@ class AuthUsersController < ApplicationController
|
|||
def update
|
||||
@auth_user = load_auth_user
|
||||
|
||||
if @auth_user.update_with_password(auth_user_params)
|
||||
# If the user has a password, then the `current_password` field is required
|
||||
# when updating. If not, then it's not!
|
||||
success = @auth_user.uses_password? ?
|
||||
@auth_user.update_with_password(auth_user_params) :
|
||||
@auth_user.update(auth_user_params)
|
||||
|
||||
if success
|
||||
# NOTE: Changing the password will sign you out, so make sure we stay
|
||||
# signed in!
|
||||
bypass_sign_in @auth_user, scope: :auth_user
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
|
||||
<%# Current password is only required if you have one! %>
|
||||
<% if @auth_user.uses_password? %>
|
||||
<fieldset>
|
||||
<div class="field">
|
||||
<%= f.label :current_password %>
|
||||
|
@ -46,6 +48,7 @@
|
|||
<%= f.password_field :current_password, autocomplete: "current-password" %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit "Save changes" %>
|
||||
|
|
Loading…
Reference in a new issue