Commit b78822b 1 parent aa6a165 commit b78822b Copy full SHA for b78822b
File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 17
17
18
18
from .auth import Authentication
19
19
from .db import Database
20
- from .models import User , UserGroup
20
+ from .models import User , UserGroup , UserProfile
21
21
22
22
23
23
async def setup_admin_group (db ):
@@ -29,18 +29,22 @@ async def setup_admin_group(db):
29
29
30
30
31
31
async def setup_admin_user (db , username , admin_group ):
32
- user_obj = await db .find_one (User , username = username )
32
+ user_obj = await db .find_one_by_attributes (User ,
33
+ {'profile.username' : username })
33
34
if user_obj :
34
35
print (f"User { username } already exists, aborting." )
35
36
print (user_obj .json ())
36
37
return None
37
38
password = getpass .getpass (f"Password for user '{ args .username } ': " )
38
39
hashed_password = Authentication .get_password_hash (password )
39
40
print (f"Creating { username } user..." )
40
- return await db . create ( User (
41
+ profile = UserProfile (
41
42
username = username ,
42
43
hashed_password = hashed_password ,
43
44
groups = [admin_group ]
45
+ )
46
+ return await db .create (User (
47
+ profile = profile
44
48
))
45
49
46
50
You can’t perform that action at this time.
0 commit comments