|
|
@ -65,23 +65,24 @@ export class AuthService { |
|
|
user = await this.usersService.create({ |
|
|
user = await this.usersService.create({ |
|
|
name, |
|
|
name, |
|
|
email, |
|
|
email, |
|
|
googleId, |
|
|
|
|
|
avatar: picture, |
|
|
|
|
|
lastLoginAt: new Date(), |
|
|
|
|
|
}) |
|
|
}) |
|
|
} else { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (user.googleId !== googleId) { |
|
|
user.googleId = googleId |
|
|
user.googleId = googleId |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (!user.name) { |
|
|
|
|
|
user.name = name |
|
|
|
|
|
} |
|
|
|
|
|
if (!user.avatar) { |
|
|
|
|
|
user.avatar = picture |
|
|
|
|
|
} |
|
|
|
|
|
user.lastLoginAt = new Date() |
|
|
|
|
|
await user.save() |
|
|
|
|
|
|
|
|
if (user.name !== name) { |
|
|
|
|
|
user.name = name |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (user.avatar !== picture) { |
|
|
|
|
|
user.avatar = picture |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
user.lastLoginAt = new Date() |
|
|
|
|
|
await user.save() |
|
|
|
|
|
|
|
|
const payload = { email: user.email, sub: user._id } |
|
|
const payload = { email: user.email, sub: user._id } |
|
|
return { |
|
|
return { |
|
|
accessToken: this.jwtService.sign(payload), |
|
|
accessToken: this.jwtService.sign(payload), |
|
|
@ -107,9 +108,11 @@ export class AuthService { |
|
|
const user = await this.usersService.create({ |
|
|
const user = await this.usersService.create({ |
|
|
...userData, |
|
|
...userData, |
|
|
password: hashedPassword, |
|
|
password: hashedPassword, |
|
|
lastLoginAt: new Date(), |
|
|
|
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
user.lastLoginAt = new Date() |
|
|
|
|
|
await user.save() |
|
|
|
|
|
|
|
|
const payload = { email: user.email, sub: user._id } |
|
|
const payload = { email: user.email, sub: user._id } |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
|