fix issues in core
This commit is contained in:
@@ -31,6 +31,7 @@ export class User {
|
||||
this.id = props.id;
|
||||
this.displayName = props.displayName.trim();
|
||||
this.email = props.email;
|
||||
this.passwordHash = props.passwordHash;
|
||||
this.iracingCustomerId = props.iracingCustomerId;
|
||||
this.primaryDriverId = props.primaryDriverId;
|
||||
this.avatarUrl = props.avatarUrl;
|
||||
@@ -52,18 +53,20 @@ export class User {
|
||||
}
|
||||
|
||||
public static fromStored(stored: StoredUser): User {
|
||||
const passwordHash = stored.passwordHash ? PasswordHash.fromHash(stored.passwordHash) : undefined;
|
||||
const userProps: any = {
|
||||
const passwordHash = stored.passwordHash
|
||||
? PasswordHash.fromHash(stored.passwordHash)
|
||||
: undefined;
|
||||
|
||||
const userProps: UserProps = {
|
||||
id: UserId.fromString(stored.id),
|
||||
displayName: stored.displayName,
|
||||
email: stored.email,
|
||||
...(stored.email !== undefined ? { email: stored.email } : {}),
|
||||
...(passwordHash !== undefined ? { passwordHash } : {}),
|
||||
...(stored.primaryDriverId !== undefined
|
||||
? { primaryDriverId: stored.primaryDriverId }
|
||||
: {}),
|
||||
};
|
||||
if (passwordHash) {
|
||||
userProps.passwordHash = passwordHash;
|
||||
}
|
||||
if (stored.primaryDriverId) {
|
||||
userProps.primaryDriverId = stored.primaryDriverId;
|
||||
}
|
||||
|
||||
return new User(userProps);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user