From a6cdd93a660b031d4a6bf2219f0bef0058dd6831 Mon Sep 17 00:00:00 2001 From: msdundar Date: Sun, 26 Mar 2017 01:58:09 +0300 Subject: [PATCH 1/3] Fix #1406. Registration form consistency with User model --- app/models/user.rb | 2 +- app/views/devise/registrations/new.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 05edcce6..2f5d41e8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -53,7 +53,7 @@ class User < ActiveRecord::Base scope :admin, -> { where(is_admin: true) } - validates :email, presence: true + validates :email, :password, :password_confirmation, presence: true validates :username, uniqueness: { diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 36eeb6e3..0b434870 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -9,7 +9,7 @@ = semantic_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| = f.input :username, input_html: { required: true } = f.input :email, input_html: { required: true } - = f.input :name, input_html: { required: true } + = f.input :name = f.input :password, input_html: { required: true } = f.input :password_confirmation, input_html: { required: true } %p.text-right From a659cb615af1f9c68baa33f3001ba5faf1e1b744 Mon Sep 17 00:00:00 2001 From: msdundar Date: Sun, 26 Mar 2017 02:30:24 +0300 Subject: [PATCH 2/3] Fix #1409. Add a label for email_public and hide openids when they are not present --- app/views/devise/ichain_sessions/new.html.haml | 3 --- app/views/devise/registrations/edit.html.haml | 15 ++++++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/views/devise/ichain_sessions/new.html.haml b/app/views/devise/ichain_sessions/new.html.haml index 0d873e06..17085775 100644 --- a/app/views/devise/ichain_sessions/new.html.haml +++ b/app/views/devise/ichain_sessions/new.html.haml @@ -10,11 +10,8 @@ = f.input :url, as: :hidden, input_html: { value: @back_url } = f.input :context, as: :hidden, input_html: { value: @context } = f.input :proxypath, as: :hidden, input_html: { value: @proxypath } - = f.input :username, input_html: { autofocus: true } = f.input :password, as: :password - %p.text-right = f.action :submit, as: :button, label: 'Sign In', button_html: { class: 'btn btn-success' } - = render partial: 'devise/shared/help' diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index d97b4867..ce3bb7d5 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -2,21 +2,22 @@ .row .col-md-12 .page-header - %h1 Edit your Account + %h1 Edit Your Account .row .col-md-12 = semantic_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| = f.input :username, required: false, input_html: { autocomplete: 'off' } = f.input :email, required: false, input_html: { autocomplete: 'off' } - = f.input :email_public + = f.input :email_public, label: "Make my email public" = f.input :password, hint: "(Leave blank if you don't want to change it)", input_html: { autocomplete: 'off' } = f.input :password_confirmation, input_html: { autocomplete: 'off' } = f.inputs name: 'OpenID' do - %h4 - Currently the following openIDs are associated with your account - - @openids.each do |openid| - %li= "#{openid.provider}:#{openid.email}" - %br + - if @openids.present? + %h4 + Currently the following openIDs are associated with your account + - @openids.each do |openid| + %li= "#{openid.provider}:#{openid.email}" + %br %h4 To add an openID with a different email address to your account, sign in with your openID while logged in to OSEM From acbc7df96a96807e5c893fe52a7573525f27ef55 Mon Sep 17 00:00:00 2001 From: msdundar Date: Sun, 26 Mar 2017 02:55:19 +0300 Subject: [PATCH 3/3] Fix #1406. Validate password only on create --- app/models/user.rb | 3 ++- app/views/devise/sessions/new.html.haml | 2 +- app/views/users/edit.html.haml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 2f5d41e8..2784512e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -53,7 +53,8 @@ class User < ActiveRecord::Base scope :admin, -> { where(is_admin: true) } - validates :email, :password, :password_confirmation, presence: true + validates :email, presence: true + validates :password, :password_confirmation, presence: true, on: :create validates :username, uniqueness: { diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 2c1bb613..3e2d5667 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -7,7 +7,7 @@ Sign In .panel-body = semantic_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| - = f.input :login + = f.input :login, label: "Username / Email" = f.input :password - if devise_mapping.rememberable? %p.text-right.small diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index f199347f..85e91d39 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -11,7 +11,7 @@ .control-label = "Avatar" = image_tag(@user.gravatar_url(size: '48'), title: "Yo #{@user.name}!", alt: '') - = link_to 'Change your avatar here', 'https://gravatar.com' + = link_to 'Change your avatar here', 'https://gravatar.com', target: :_blank = f.input :affiliation, as: :string, hint: 'This could be a company, a user group, or nothing at all.' = f.input :biography, input_html: { rows: 5, data: { provide: 'markdown-editable' } },