浏览代码

add in_context option to authentificate method

Guénaël Muller 7 年前
父节点
当前提交
8ee655dd6c
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      tracim/lib/core/user.py

+ 3 - 2
tracim/lib/core/user.py 查看文件

95
         except:
95
         except:
96
             return False
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
         Authenticate user with email and password, raise AuthenticationFailed
100
         Authenticate user with email and password, raise AuthenticationFailed
101
         if uncorrect.
101
         if uncorrect.
102
         :param email: email of the user
102
         :param email: email of the user
103
         :param password: cleartext password of the user
103
         :param password: cleartext password of the user
104
+        :param in_context:
104
         :return: User who was authenticated.
105
         :return: User who was authenticated.
105
         """
106
         """
106
         try:
107
         try:
107
             user = self.get_one_by_email(email)
108
             user = self.get_one_by_email(email)
108
             if user.validate_password(password):
109
             if user.validate_password(password):
109
-                return user
110
+                return self._get_correct_user_type(user, in_context=in_context)
110
             else:
111
             else:
111
                 raise BadUserPassword()
112
                 raise BadUserPassword()
112
         except (BadUserPassword, NoResultFound):
113
         except (BadUserPassword, NoResultFound):