Skip to content

Commit 4658c18

Browse files
normalize email before saving/using it in the session
1 parent bc346c9 commit 4658c18

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

app/models/api_authentication/session.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class ApiAuthentication::Session < ApiAuthentication::ApplicationRecord
3030

3131
validate :user_is_not_blocked
3232

33+
before_validation :normalize_email
3334
before_validation :assign_user, if: :email_login?
3435
before_validation :assign_or_create_new_user, on: :create, if: :social_login?
3536

@@ -45,6 +46,13 @@ def offline!
4546

4647
private
4748

49+
#
50+
# CALLBACKs
51+
#
52+
def normalize_email
53+
self.email = self.email.to_s.downcase.presence
54+
end
55+
4856
def assign_user
4957
self.user ||= user_via_email
5058
end

lib/api_authentication/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ApiAuthentication
2-
VERSION = '0.2.2'
2+
VERSION = '0.2.3'
33
end

0 commit comments

Comments
 (0)