File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 44import pyotp
55import base64
66import os
7+ from datetime import datetime
78
89db = SQLAlchemy ()
910
@@ -13,6 +14,9 @@ class User(UserMixin, db.Model):
1314 password_hash = db .Column (db .String (120 ), nullable = False )
1415 totp_secret = db .Column (db .String (32 ), nullable = True )
1516 totp_enabled = db .Column (db .Boolean , default = False )
17+ is_admin = db .Column (db .Boolean , default = False )
18+ created_at = db .Column (db .DateTime , default = datetime .utcnow )
19+ last_login = db .Column (db .DateTime , nullable = True )
1620
1721 def set_password (self , password ):
1822 self .password_hash = generate_password_hash (password )
@@ -36,3 +40,13 @@ def get_totp_uri(self):
3640 name = self .username ,
3741 issuer_name = 'DirectAdmin Email Forwarder'
3842 )
43+
44+ def to_dict (self ):
45+ return {
46+ 'id' : self .id ,
47+ 'username' : self .username ,
48+ 'is_admin' : self .is_admin ,
49+ 'totp_enabled' : self .totp_enabled ,
50+ 'created_at' : self .created_at .isoformat () if self .created_at else None ,
51+ 'last_login' : self .last_login .isoformat () if self .last_login else None
52+ }
You can’t perform that action at this time.
0 commit comments