chore: added types to createProviderAccount ,ethod in auth.service file

This commit is contained in:
Balu Babu
2023-01-19 04:55:51 +05:30
parent 813db4a985
commit 82dee95cd0
6 changed files with 23 additions and 24 deletions

View File

@@ -224,7 +224,10 @@ export class AuthService {
statusCode: HttpStatus.NOT_FOUND,
});
// Check to see if entry for magic-link is present in the Account table for this user
/**
* * Check to see if entry for Magic-Link is present in the Account table for user
* * If user was created with another provider findUserByEmail may return true
*/
const profile = {
provider: 'email',
id: user.value.email,

View File

@@ -20,7 +20,6 @@ export class GithubStrategy extends PassportStrategy(Strategy) {
}
async validate(accessToken, refreshToken, profile, done) {
console.dir(profile);
const user = await this.usersService.findUserByEmail(
profile.emails[0].value,
);
@@ -34,7 +33,10 @@ export class GithubStrategy extends PassportStrategy(Strategy) {
return createdUser;
}
// Check to see if entry for github is present in the Account table for this user
/**
* * Check to see if entry for Github is present in the Account table for user
* * If user was created with another provider findUserByEmail may return true
*/
const providerAccountExists =
await this.authService.checkIfProviderAccountExists(user.value, profile);

View File

@@ -33,7 +33,10 @@ export class GoogleStrategy extends PassportStrategy(Strategy) {
return createdUser;
}
// Check to see if entry for google is present in the Account table for this user
/**
* * Check to see if entry for Google is present in the Account table for user
* * If user was created with another provider findUserByEmail may return true
*/
const providerAccountExists =
await this.authService.checkIfProviderAccountExists(user.value, profile);

View File

@@ -40,27 +40,10 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
if (!payload) throw new ForbiddenException(INVALID_ACCESS_TOKEN);
const user = await this.usersService.findUserById(payload.sub);
if (O.isNone(user)) {
throw new UnauthorizedException(USER_NOT_FOUND);
}
const profile = {
provider: 'email',
id: user.value.email,
};
const providerAccountExists =
await this.authService.checkIfProviderAccountExists(user.value, profile);
if (!providerAccountExists)
await this.usersService.createProviderAccount(
user.value,
null,
null,
profile,
);
return user.value;
}
}

View File

@@ -33,7 +33,10 @@ export class MicrosoftStrategy extends PassportStrategy(Strategy) {
return createdUser;
}
// Check to see if entry for microsoft is present in the Account table for this user
/**
* * Check to see if entry for Microsoft is present in the Account table for user
* * If user was created with another provider findUserByEmail may return true
*/
const providerAccountExists =
await this.authService.checkIfProviderAccountExists(user.value, profile);