-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserModel.py
More file actions
26 lines (22 loc) · 971 Bytes
/
Copy pathUserModel.py
File metadata and controls
26 lines (22 loc) · 971 Bytes
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
import datetime
import typing
import uuid
class User:
def __init__(self,username:str,password:str,token:str='',expired_date:str='',access_level:int=0,id:str=''):
self.id=id if id else str(uuid.uuid4())
self.username=username
self.password=password
self.token=token if token else str(uuid.uuid4())
self.expired_date=expired_date if expired_date else (datetime.datetime.now()+datetime.timedelta(30)).strftime("%Y-%m-%d, %H:%M:%S")
self.access_level=access_level
def json(self):
return {
'id':self.id,
'username':self.username,
'password':self.password,
'token':self.token,
'expired_date':self.expired_date,
'access_level':self.access_level
}
def extend_date(self):
self.expired_date=(datetime.datetime.strptime(self.expired_date,"%Y-%m-%d, %H:%M:%S")+datetime.timedelta(30)).strftime("%Y-%m-%d, %H:%M:%S")