Skip to content

Commit

Permalink
normalize email before saving/using it in the session
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroStepaniuk committed Dec 11, 2018
1 parent bc346c9 commit 4658c18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/models/api_authentication/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ApiAuthentication::Session < ApiAuthentication::ApplicationRecord

validate :user_is_not_blocked

before_validation :normalize_email
before_validation :assign_user, if: :email_login?
before_validation :assign_or_create_new_user, on: :create, if: :social_login?

Expand All @@ -45,6 +46,13 @@ def offline!

private

#
# CALLBACKs
#
def normalize_email
self.email = self.email.to_s.downcase.presence
end

def assign_user
self.user ||= user_via_email
end
Expand Down
2 changes: 1 addition & 1 deletion lib/api_authentication/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ApiAuthentication
VERSION = '0.2.2'
VERSION = '0.2.3'
end

0 comments on commit 4658c18

Please sign in to comment.