Admin and api user password now checked on browser side #2517

This commit is contained in:
Priit Tark 2015-08-19 00:03:58 +03:00
parent 6eaf6badc0
commit aad7884c0e
2 changed files with 31 additions and 13 deletions

View file

@ -1,3 +1,10 @@
- if @admin_user.new_record?
- overwrite_required = ''
- field_required = 'required'
- else
- overwrite_required = 'not-required' # otherwise automatic one adds required
- field_required = ''
= form_for([:admin, @admin_user], html: { class: 'form-horizontal', autocomplete: 'off' }) do |f| = form_for([:admin, @admin_user], html: { class: 'form-horizontal', autocomplete: 'off' }) do |f|
= render 'shared/full_errors', object: @admin_user = render 'shared/full_errors', object: @admin_user
@ -11,22 +18,22 @@
- if @admin_user.new_record? || can?(:update, AdminUser) - if @admin_user.new_record? || can?(:update, AdminUser)
.form-group .form-group
.col-md-4.control-label .col-md-4.control-label
- not_required = @admin_user.new_record? ? '' : 'not-required'
= f.label :password, class: not_required = f.label :password, class: overwrite_required
.col-md-8 .col-md-8
= f.text_field(:password, class: 'form-control') = f.text_field(:password, class: "form-control #{field_required}")
.form-group .form-group
.col-md-4.control-label .col-md-4.control-label
= f.label :password_confirmation, class: not_required = f.label :password_confirmation, class: overwrite_required
.col-md-8 .col-md-8
= f.text_field(:password_confirmation, class: 'form-control') = f.text_field(:password_confirmation, class: "form-control #{field_required}")
%hr %hr
.form-group .form-group
.col-md-4.control-label .col-md-4.control-label
= f.label :identity_code = f.label :identity_code
.col-md-8 .col-md-8
= f.text_field(:identity_code, class: 'form-control') = f.text_field(:identity_code, class: 'form-control required')
.form-group .form-group
.col-md-4.control-label .col-md-4.control-label
= f.label :email = f.label :email
@ -37,13 +44,15 @@
= f.label :country_code, t(:country) = f.label :country_code, t(:country)
.col-md-8 .col-md-8
= f.select(:country_code, = f.select(:country_code,
SortedCountry.all_options(f.object.country_code), {}, class: 'form-control') SortedCountry.all_options(f.object.country_code), {}, class: 'form-control required')
%hr %hr
.form-group .form-group
.col-md-4.control-label .col-md-4.control-label
= f.label :role = f.label :role, class: 'required'
.col-md-8 .col-md-8
= select_tag 'admin_user[roles][]', options_for_select(AdminUser::ROLES.map {|x| [t(x), x] }, @admin_user.roles.try(:first)), class: 'form-control selectize' = select_tag 'admin_user[roles][]',
options_for_select(AdminUser::ROLES.map {|x| [t(x), x] },
@admin_user.roles.try(:first)), class: 'form-control selectize'
%hr %hr
.row .row

View file

@ -1,3 +1,11 @@
- if @api_user.new_record?
- overwrite_required = ''
- field_required = 'required'
- else
- overwrite_required = 'not-required' # otherwise automatic one adds required
- field_required = ''
= form_for([:admin, @api_user], multipart: true, = form_for([:admin, @api_user], multipart: true,
html: {class: 'form-horizontal', autocomplete: 'off'}) do |f| html: {class: 'form-horizontal', autocomplete: 'off'}) do |f|
= render 'shared/full_errors', object: @api_user = render 'shared/full_errors', object: @api_user
@ -11,16 +19,16 @@
= f.text_field(:username, class: 'form-control') = f.text_field(:username, class: 'form-control')
.form-group .form-group
.col-md-4.control-label .col-md-4.control-label
- not_required = @api_user.new_record? ? '' : 'not-required' = f.label :password, class: overwrite_required
= f.label :password, class: not_required
.col-md-7 .col-md-7
= f.text_field :password, class: 'form-control', autocomplete: 'off' = f.text_field :password, class: "form-control #{field_required}", autocomplete: 'off'
.form-group .form-group
.col-md-4.control-label .col-md-4.control-label
= f.label :identity_code = f.label :identity_code
.col-md-7 .col-md-7
= f.text_field(:identity_code, class: 'form-control') = f.text_field(:identity_code, class: 'form-control')
.form-group .form-group
.form-group.has-feedback.js-typeahead-container .form-group.has-feedback.js-typeahead-container
.col-md-4.control-label .col-md-4.control-label
@ -32,9 +40,10 @@
%span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden %span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden
%span.glyphicon.glyphicon-remove.form-control-feedback.js-typeahead-remove %span.glyphicon.glyphicon-remove.form-control-feedback.js-typeahead-remove
= f.hidden_field(:registrar_id, class: 'js-registrar-id') = f.hidden_field(:registrar_id, class: 'js-registrar-id')
.form-group .form-group
.col-md-4.control-label .col-md-4.control-label
= f.label :role = f.label :role, class: 'required'
.col-md-7 .col-md-7
= select_tag 'api_user[roles][]', = select_tag 'api_user[roles][]',
options_for_select(ApiUser::ROLES.map {|x| [t(x), x] }, @api_user.roles.try(:first)), options_for_select(ApiUser::ROLES.map {|x| [t(x), x] }, @api_user.roles.try(:first)),