mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Fix registration form
- Admins should be able to change admin status - Username should not be changeable - always require password confirmation
This commit is contained in:
parent
6304466696
commit
7babc5d08a
2 changed files with 18 additions and 22 deletions
|
|
@ -26,14 +26,9 @@ class RegistrationsController < Devise::RegistrationsController
|
||||||
end
|
end
|
||||||
|
|
||||||
def account_update_params
|
def account_update_params
|
||||||
params.require(:user).permit(
|
user_attributes = [:email, :name, :password, :password_confirmation, :current_password, :email_public]
|
||||||
:email,
|
user_attributes << :is_admin if current_user.is_admin?
|
||||||
:password,
|
params.require(:user).permit(user_attributes)
|
||||||
:password_confirmation,
|
|
||||||
:current_password,
|
|
||||||
:username,
|
|
||||||
:email_public
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_captcha
|
def check_captcha
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
.form-group
|
- unless @user.persisted?
|
||||||
= f.label :username
|
.form-group
|
||||||
%abbr{title: 'This field is required'} *
|
= f.label :username
|
||||||
= f.text_field :username, required: true, autocomplete: 'off', class: 'form-control', placeholder: 'Username'
|
%abbr{title: 'This field is required'} *
|
||||||
|
= f.text_field :username, required: true, autocomplete: 'off', class: 'form-control', placeholder: 'Username'
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :email
|
= f.label :email
|
||||||
%abbr{title: 'This field is required'} *
|
%abbr{title: 'This field is required'} *
|
||||||
|
|
@ -10,17 +11,17 @@
|
||||||
.checkbox
|
.checkbox
|
||||||
%label
|
%label
|
||||||
= f.check_box :email_public
|
= f.check_box :email_public
|
||||||
Check if you want your email address to appear publicly (e.g. on sessions, registration lists, etc.)
|
Do you want your email address to appear publicly
|
||||||
.form-group
|
%span.help-block
|
||||||
= f.label :name, 'Real Name'
|
For instance on sessions pages or registration lists.
|
||||||
= f.text_field :name, required: true, class: 'form-control', placeholder: 'Name'
|
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :password, 'Password'
|
= f.label :password, 'Password'
|
||||||
%abbr{title: 'This field is required'} *
|
- if !@user.persisted?
|
||||||
= f.password_field :password, required: true, class: 'form-control', placeholder: 'Password'
|
%abbr{title: 'This field is required'} *
|
||||||
|
= f.password_field :password, required: !@user.persisted?, class: 'form-control', placeholder: 'Password'
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :password_confirmation, 'Password Confirmation'
|
= f.label :password_confirmation, 'Password Confirmation'
|
||||||
= f.password_field :password_confirmation, required: true, class: 'form-control', placeholder: 'Password Confirmation'
|
= f.password_field :password_confirmation, required: !@user.persisted?, class: 'form-control', placeholder: 'Password Confirmation'
|
||||||
- if @user.persisted?
|
- if @user.persisted?
|
||||||
%p.text-muted
|
%p.text-muted
|
||||||
Leave blank if you don't want to change your password
|
Leave blank if you don't want to change your password
|
||||||
|
|
@ -32,16 +33,16 @@
|
||||||
is Admin?
|
is Admin?
|
||||||
%span.help-block
|
%span.help-block
|
||||||
An admin can create a new conference, manage users and make other users admins.
|
An admin can create a new conference, manage users and make other users admins.
|
||||||
- elsif @user.persisted?
|
- if @user.persisted?
|
||||||
%h4
|
%h4
|
||||||
Confirmation
|
Confirmation
|
||||||
%hr
|
%hr
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :password, "Current Password"
|
= f.label :password, "Current Password"
|
||||||
%abbr{title: 'This field is required'} *
|
%abbr{title: 'This field is required'} *
|
||||||
= f.password_field :current_password, autocomplete: 'off', class: 'form-control', placeholder: 'Password'
|
= f.password_field :current_password, required: true, autocomplete: 'off', class: 'form-control', placeholder: 'Password'
|
||||||
%p.text-muted
|
%p.text-muted
|
||||||
We need your current password to confirm password, email or username changes
|
We need your current password to confirm changes
|
||||||
- Feature.with(:recaptcha) do
|
- Feature.with(:recaptcha) do
|
||||||
.form-group
|
.form-group
|
||||||
= recaptcha_tags
|
= recaptcha_tags
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue