forked from ubergesundheit/dialogmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add user edit ability, allow to specify username
- Loading branch information
1 parent
5cb866c
commit 11b14ec
Showing
14 changed files
with
200 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class RegistrationsController < Devise::RegistrationsController | ||
def update | ||
@user = User.find(current_user.id) | ||
|
||
successfully_updated = if needs_password?(@user) | ||
@user.update_with_password(devise_parameter_sanitizer.sanitize(:account_update)) | ||
else | ||
# remove the virtual current_password attribute | ||
# update_without_password doesn't know how to ignore it | ||
params[:user].delete(:current_password) | ||
@user.update_without_password(devise_parameter_sanitizer.sanitize(:account_update)) | ||
end | ||
|
||
if successfully_updated | ||
head :no_content | ||
else | ||
render json: { errors: @user.errors }, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
private | ||
|
||
# check if we need password to update user data | ||
# ie if user signed in via an external provider | ||
def needs_password?(user) | ||
Identity.where(user_id: user.id).count == 0 | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
class UserSerializer < ActiveModel::Serializer | ||
attributes :id, :email, :name, :confirmed | ||
attributes :id, :email, :name, :confirmed, :external_auth | ||
|
||
def confirmed | ||
object.confirmed? | ||
end | ||
|
||
def external_auth | ||
Identity.where(user_id: object.id).count != 0 | ||
end | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,17 @@ | |
#error_explanation | ||
Fehler: | ||
- current_user.errors.full_messages.each do |msg| | ||
= msg | ||
%p | ||
= msg | ||
%p.help-block Leider wird bei der Authentifizierung mit Twitter keine E-Mail Adresse mitgeschickt. Bitte vervollständige sie an dieser Stelle, damit andere Benutzer dich eindeutig identifizieren können. | ||
= current_user.name | ||
#form-group | ||
.form-group | ||
= f.label :name, "Benutzername (mindestens 4 Zeichen)" | ||
.controls | ||
= f.text_field :name, :autofocus => true, :value => current_user.name, class: 'form-control', required: true, pattern: ".{4,}" | ||
.form-group | ||
= f.label :email | ||
#controls | ||
= f.text_field :email, :autofocus => true, :value => '', class: 'form-control', placeholder: '[email protected]' | ||
.controls | ||
= f.text_field :email, :autofocus => true, :value => '', class: 'form-control', placeholder: '[email protected]', required: true, type: "email" | ||
%p.no-spam Es wird kein Spam versendet! | ||
#actions | ||
= f.submit 'Speichern und Fortfahren' |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class NameUniqueToUsers < ActiveRecord::Migration | ||
def change | ||
add_index :users, :name, :unique => true | ||
end | ||
end |
This file contains 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