server: migrations: add migration for UserInDatabase2

This commit is contained in:
Jesse Chan
2020-10-11 11:32:24 +08:00
parent cf08d68c92
commit 34b5e09753
6 changed files with 125 additions and 20 deletions
+4 -4
View File
@@ -75,7 +75,8 @@ class Users {
createUser(
credentials: Credentials,
callback: (data: {username: Required<Credentials['username']>} | null, error?: Error) => void,
callback: (user: UserInDatabase | null, error?: Error) => void,
shouldHash = true,
): void {
if (this.db == null) {
return callback(null, new Error('Users database is not ready.'));
@@ -87,7 +88,7 @@ class Users {
this.db.insert(
{
...credentials,
password: hash.encoded,
password: shouldHash ? hash.encoded : credentials.password,
},
(error, user) => {
if (error) {
@@ -98,8 +99,7 @@ class Users {
return callback(null, error);
}
services.bootstrapServicesForUser(user as UserInDatabase);
return callback({username: credentials.username});
return callback(user as UserInDatabase);
},
);
})