From acbc7df96a96807e5c893fe52a7573525f27ef55 Mon Sep 17 00:00:00 2001 From: msdundar Date: Sun, 26 Mar 2017 02:55:19 +0300 Subject: [PATCH] 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' } },