Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def update
if current_user.update(user_params)

if current_user.unconfirmed_email.present?
flash[:danger] = I18n.t("devise.registrations.update_needs_confirmation")
flash[:danger] = 'Your account has been updated, but we need to verify your new email address. Please check your email and follow the confirmation link.'
else
flash[:info] = I18n.t("devise.registrations.updated")
flash[:info] = 'Your account has been updated successfully.'
end

redirect_to (session.delete(:target) || root_url)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def authenticate_with_hash(user = nil)
flash.now[:info] = "You have signed in with #{auth_hash.provider_name}."
logger.info "Signing in user #{@user.inspect}"

@user.skip_confirmation!
@user.confirmed_at = Time.current
sign_in @user

redirect_to after_sign_in_path_for(@user)
Expand Down
2 changes: 1 addition & 1 deletion app/models/speaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Speaker < ApplicationRecord
validates :event, presence: true
validates :bio, length: {maximum: 500}
validates :name, :email, presence: true, unless: :skip_name_email_validation
validates_format_of :email, with: Devise.email_regexp
validates_format_of :email, with: /\A[^@\s]+@[^@\s]+\z/ # equivalent to Devise.email_regexp

attr_accessor :skip_name_email_validation

Expand Down
10 changes: 5 additions & 5 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class User < ApplicationRecord
validates :bio, length: { maximum: 500 }
validates :name, presence: true, allow_nil: true
validates_uniqueness_of :email, allow_blank: true
validates_format_of :email, with: Devise.email_regexp, allow_blank: true, if: :email_changed?
validates_format_of :email, with: /\A[^@\s]+@[^@\s]+\z/, allow_blank: true, if: :email_changed? # equivalent to Devise.email_regexp
validates_presence_of :email, on: :create, if: -> { provider.blank? && identities.blank? }
validates_presence_of :email, on: :update, if: -> { provider.blank? || unconfirmed_email.blank? }
validates_presence_of :password, on: :create
validates_confirmation_of :password, on: :create
validates_length_of :password, within: Devise.password_length, allow_blank: true
validates_length_of :password, within: 6..128, allow_blank: true

before_create :check_pending_invite_email

Expand Down Expand Up @@ -58,21 +58,21 @@ def self.create_from_omniauth!(auth, invitation_email = nil)
user = new(
name: auth['info']['name'],
email: invitation_email || auth['info']['email'] || '',
password: (password = Devise.friendly_token[0, 20]),
password: (password = SecureRandom.hex(10)),
password_confirmation: password
)
user.identities.build(provider: auth.provider, uid: auth.uid, account_name: auth.account_name)

if invitation_email.present? && (user.email == invitation_email)
user.skip_confirmation!
user.confirmed_at = Time.current
end

user.tap(&:save!)
end

def check_pending_invite_email
if pending_invite_email.present? && pending_invite_email == email
skip_confirmation!
self.confirmed_at = Time.current
end
end

Expand Down