-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser.py
47 lines (36 loc) · 1.09 KB
/
user.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from flask_login import UserMixin
class User(UserMixin):
def __init__(self, user_name) -> None:
self._user_name = user_name
self._is_active = True
self._is_anonymous = False
self._is_authenticated = False
@property
def is_authenticated(self):
return self._is_authenticated
@is_authenticated.setter
def is_authenticated(self, a):
self._is_authenticated = a
@property
def is_active(self):
return self._is_active
@is_active.setter
def is_active(self, a):
self._is_active = a
@property
def is_anonymous(self):
return self._is_anonymous
@is_anonymous.setter
def is_anonymous(self, a):
self._is_anonymous = a
@property
def name(self):
return self._user_name
def get_id(self):
return self._user_name
def verify_pwd(self, request_pwd, pwd):
if request_pwd and pwd:
self.is_authenticated = request_pwd == pwd
else:
self.is_authenticated = False
self.is_anonymous = not self.is_authenticated