Pārlūkot izejas kodu

add in_context option to authentificate method

Guénaël Muller 7 gadus atpakaļ
vecāks
revīzija
8ee655dd6c
1 mainītis faili ar 3 papildinājumiem un 2 dzēšanām
  1. 3 2
      tracim/lib/core/user.py

+ 3 - 2
tracim/lib/core/user.py Parādīt failu

@@ -95,18 +95,19 @@ class UserApi(object):
95 95
         except:
96 96
             return False
97 97
 
98
-    def authenticate_user(self, email, password) -> User:
98
+    def authenticate_user(self, email, password, in_context=False) -> User:
99 99
         """
100 100
         Authenticate user with email and password, raise AuthenticationFailed
101 101
         if uncorrect.
102 102
         :param email: email of the user
103 103
         :param password: cleartext password of the user
104
+        :param in_context:
104 105
         :return: User who was authenticated.
105 106
         """
106 107
         try:
107 108
             user = self.get_one_by_email(email)
108 109
             if user.validate_password(password):
109
-                return user
110
+                return self._get_correct_user_type(user, in_context=in_context)
110 111
             else:
111 112
                 raise BadUserPassword()
112 113
         except (BadUserPassword, NoResultFound):