Update.
This commit is contained in:
parent
b9ca88702c
commit
dac1367aa7
@ -21,6 +21,7 @@ class AuthService {
|
||||
id: authData.userId,
|
||||
username: authData.username
|
||||
};
|
||||
this.notifyAuthChange();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -29,11 +30,18 @@ class AuthService {
|
||||
async login(username, password, remember = true) {
|
||||
const result = await this.api.login(username, password);
|
||||
if (result.success) {
|
||||
let actualUsername = username;
|
||||
try {
|
||||
const profileResult = await this.api.getProfile(result.authToken.user_id);
|
||||
if (profileResult?.success && profileResult.profile?.username) {
|
||||
actualUsername = profileResult.profile.username;
|
||||
}
|
||||
} catch (e) {}
|
||||
const authData = {
|
||||
tokenId: result.authToken.id,
|
||||
tokenKey: result.authToken.key,
|
||||
userId: result.authToken.user_id,
|
||||
username: username,
|
||||
username: actualUsername,
|
||||
expireTime: result.authToken.expire_time
|
||||
};
|
||||
if (remember) {
|
||||
@ -41,7 +49,7 @@ class AuthService {
|
||||
}
|
||||
this.currentUser = {
|
||||
id: authData.userId,
|
||||
username: username
|
||||
username: actualUsername
|
||||
};
|
||||
this.notifyAuthChange();
|
||||
return { success: true, user: this.currentUser };
|
||||
|
||||
Loading…
Reference in New Issue
Block a user