feat(login by email option): added ability to log in with user primary email. Fixes: RCCE-63
This commit is contained in:
parent
5f36eb1b22
commit
d8281bb5c0
7 changed files with 28 additions and 14 deletions
|
|
@ -35,7 +35,7 @@ import collections
|
|||
|
||||
from sqlalchemy import (
|
||||
or_, and_, not_, func, cast, TypeDecorator, event, select,
|
||||
true, false, null,
|
||||
true, false, null, union_all,
|
||||
Index, Sequence, UniqueConstraint, ForeignKey, CheckConstraint, Column,
|
||||
Boolean, String, Unicode, UnicodeText, DateTime, Integer, LargeBinary,
|
||||
Text, Float, PickleType, BigInteger)
|
||||
|
|
@ -953,6 +953,12 @@ class User(Base, BaseModel):
|
|||
|
||||
return cls.execute(q).scalar_one_or_none()
|
||||
|
||||
@classmethod
|
||||
def get_by_username_or_primary_email(cls, user_identifier):
|
||||
qs = union_all(cls.select().where(func.lower(cls.username) == func.lower(user_identifier)),
|
||||
cls.select().where(func.lower(cls.email) == func.lower(user_identifier)))
|
||||
return cls.execute(cls.select(User).from_statement(qs)).scalar_one_or_none()
|
||||
|
||||
@classmethod
|
||||
def get_by_auth_token(cls, auth_token, cache=False):
|
||||
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ def ValidAuth(localizer):
|
|||
|
||||
if not authenticate(username, password, '', HTTP_TYPE,
|
||||
skip_missing=True):
|
||||
user = User.get_by_username(username)
|
||||
user = User.get_by_username_or_primary_email(username)
|
||||
if user and not user.active:
|
||||
log.warning('user %s is disabled', username)
|
||||
msg = M(self, 'disabled_account', state)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue