|
|
@ -43,6 +43,9 @@ export class AuthService { |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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), |
|
|
@ -64,6 +67,7 @@ export class AuthService { |
|
|
email, |
|
|
email, |
|
|
googleId, |
|
|
googleId, |
|
|
avatar: picture, |
|
|
avatar: picture, |
|
|
|
|
|
lastLoginAt: new Date(), |
|
|
}) |
|
|
}) |
|
|
} else { |
|
|
} else { |
|
|
user.googleId = googleId |
|
|
user.googleId = googleId |
|
|
@ -74,6 +78,7 @@ export class AuthService { |
|
|
if (!user.avatar) { |
|
|
if (!user.avatar) { |
|
|
user.avatar = picture |
|
|
user.avatar = picture |
|
|
} |
|
|
} |
|
|
|
|
|
user.lastLoginAt = new Date() |
|
|
await user.save() |
|
|
await user.save() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -89,6 +94,7 @@ export class AuthService { |
|
|
const user = await this.usersService.create({ |
|
|
const user = await this.usersService.create({ |
|
|
...userData, |
|
|
...userData, |
|
|
password: hashedPassword, |
|
|
password: hashedPassword, |
|
|
|
|
|
lastLoginAt: new Date(), |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
const payload = { email: user.email, sub: user._id } |
|
|
const payload = { email: user.email, sub: user._id } |
|
|
@ -223,7 +229,10 @@ export class AuthService { |
|
|
user, |
|
|
user, |
|
|
method, |
|
|
method, |
|
|
url: url.split('?')[0], |
|
|
url: url.split('?')[0], |
|
|
ip, |
|
|
|
|
|
|
|
|
ip: |
|
|
|
|
|
request.headers['x-forwarded-for'] || |
|
|
|
|
|
request.connection.remoteAddress || |
|
|
|
|
|
ip, |
|
|
userAgent, |
|
|
userAgent, |
|
|
}) |
|
|
}) |
|
|
.catch((e) => { |
|
|
.catch((e) => { |
|
|
|