Created
August 25, 2014 14:06
-
-
Save anonymous/1ff2dc6666eb4894bcf7 to your computer and use it in GitHub Desktop.
Devise edit user without password when sign in though facebook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Users::RegistrationsController < Devise::RegistrationsController | |
before_action :configure_permitted_parameters | |
# Handles editing when provider is facebook | |
def update_resource(resource, params) | |
if current_user.provider == "facebook" | |
params.delete("current_password") | |
resource.update_without_password(params) | |
else | |
resource.update_with_password(params) | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<...> | |
<% if resource.provider != "facebook" %> | |
<div class="form-group"> | |
<%= f.label :current_password, class: "col-lg-2 control-label" %> | |
<i>(we need your current password to confirm your changes)</i> | |
<div class="col-lg-10"> | |
<%= f.password_field :current_password, autocomplete: "off", class: 'form-control' %> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :password, class: "col-lg-2 control-label" %> | |
<i>(leave blank if you don't want to change it)</i> | |
<div class="col-lg-10"> | |
<%= f.password_field :password, autocomplete: "off", class: 'form-control' %> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :password_confirmation, class: "col-lg-2 control-label" %> | |
<div class="col-lg-10"> | |
<%= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control' %> | |
</div> | |
</div> | |
<% end %> | |
<...> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment