|
@@ -6,7 +6,7 @@ import typing as typing
|
6
|
6
|
|
7
|
7
|
from tracim.models.auth import User
|
8
|
8
|
from sqlalchemy.orm.exc import NoResultFound
|
9
|
|
-from tracim.exceptions import BadUserPassword
|
|
9
|
+from tracim.exceptions import BadUserPassword, UserNotExist
|
10
|
10
|
from tracim.exceptions import AuthenticationFailed
|
11
|
11
|
from tracim.models.context_models import UserInContext
|
12
|
12
|
|
|
@@ -80,6 +80,8 @@ class UserApi(object):
|
80
|
80
|
:param in_context:
|
81
|
81
|
:return:
|
82
|
82
|
"""
|
|
83
|
+ if not self._user:
|
|
84
|
+ raise UserNotExist()
|
83
|
85
|
return self._get_correct_user_type(self._user, in_context)
|
84
|
86
|
|
85
|
87
|
def get_all(self) -> typing.Iterable[User]:
|
|
@@ -95,7 +97,11 @@ class UserApi(object):
|
95
|
97
|
except:
|
96
|
98
|
return False
|
97
|
99
|
|
98
|
|
- def authenticate_user(self, email, password, in_context=False) -> User:
|
|
100
|
+ def authenticate_user(self,
|
|
101
|
+ email: str,
|
|
102
|
+ password: str,
|
|
103
|
+ in_context=False
|
|
104
|
+ ) -> typing.Union[User, UserInContext]:
|
99
|
105
|
"""
|
100
|
106
|
Authenticate user with email and password, raise AuthenticationFailed
|
101
|
107
|
if uncorrect.
|