diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index ff58a25..78ecb7c 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -15,9 +15,9 @@ IdentifierScheme.all.each do |scheme| oauth = session["devise.#{scheme.name.downcase}_data"] unless session["devise.#{scheme.name.downcase}_data"].nil? end - + @user = User.new - + unless oauth.nil? # The OAuth provider could not be determined or there was no unique UID! if oauth[:provider].nil? || oauth[:uid].nil? @@ -26,7 +26,7 @@ else # Connect the new user with the identifier sent back by the OAuth provider flash[:notice] = t('identifier_schemes.new_login_success') - UserIdentifier.create(identifier_scheme: oauth[:provider].upcase, + UserIdentifier.create(identifier_scheme: oauth[:provider].upcase, identifier: oauth[:uid], user: @user) end @@ -78,6 +78,7 @@ @identifier_schemes = IdentifierScheme.where(active: true).order(:name) @languages = Language.sorted_by_abbreviation do_update(require_password=needs_password?(current_user, params)) + update_preferences(current_user, params) else render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false) end @@ -165,22 +166,43 @@ end end + def update_preferences(current_user, params) + prefs = params[:prefs] + # Set all preferences to false + current_user.prefs.each do |key, value| + value.each_key do |k| + current_user.prefs[key][k] = false + end + end + + # Sets the preferences the user wants to true + if prefs + prefs.each_key do |key| + prefs[key].each_key do |k| + current_user.prefs[key.to_sym][k.to_sym] = true + end + end + end + + current_user.save + end + def sign_up_params - params.require(:user).permit(:email, :password, :password_confirmation, + params.require(:user).permit(:email, :password, :password_confirmation, :firstname, :surname, :recovery_email, - :accept_terms, :other_organisation) + :accept_terms, :other_organisation, :prefs) end def update_params params.require(:user).permit(:firstname, :org_id, :other_organisation, - :language_id, :surname) + :language_id, :surname, :prefs) end def password_update params.require(:user).permit(:email, :firstname, :current_password, :org_id, :language_id, :password, :password_confirmation, :surname, - :other_organisation) + :other_organisation, :prefs) end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7e4304c..57b504f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -21,10 +21,6 @@ @perms = user_perms & [Perm.grant_permissions, Perm.modify_templates, Perm.modify_guidance, Perm.use_api, Perm.change_org_details] end - def update_preferences - - end - ## # POST - updates the permissions for a user # redirects to the admin_index action diff --git a/app/views/devise/registrations/_password_details.html.erb b/app/views/devise/registrations/_password_details.html.erb index e69de29..8ac19a3 100644 --- a/app/views/devise/registrations/_password_details.html.erb +++ b/app/views/devise/registrations/_password_details.html.erb @@ -0,0 +1,37 @@ +
\ No newline at end of file diff --git a/app/views/devise/registrations/_personal_details.html.erb b/app/views/devise/registrations/_personal_details.html.erb index b72279d..2c54efa 100644 --- a/app/views/devise/registrations/_personal_details.html.erb +++ b/app/views/devise/registrations/_personal_details.html.erb @@ -1,155 +1,115 @@<%= _("Please note that your email address is used as your username. If you change this, remember to use your new email address on sign in.") %>
+ +