Skip to content

Commit 73e847b

Browse files
author
hersveit
committed
remove casting
1 parent f7b3eb5 commit 73e847b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/services/auth/auth.service.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ import {
2222
UserPayload,
2323
} from './auth.model';
2424
import { JwtStrategy } from './strategies/jwt.strategy';
25-
import { CannotFindEmailConfirm, CannotFindUser } from '../../repositories/repositoryErrors.model';
25+
import { CannotFindEmailConfirm } from '../../repositories/repositoryErrors.model';
2626
import { User } from '@prisma/client';
2727
import { DatabaseService } from '../database/database.service';
28-
import { EmailOrPasswordIncorrect, UserAlreadyExist } from '../user/user.model';
2928

3029
@Injectable()
3130
export class AuthServiceProvider {
@@ -41,7 +40,7 @@ export class AuthServiceProvider {
4140
async signUp(payload: UserPayload) {
4241
const user = await this.userService.createUser(payload);
4342
if (isError(user)) {
44-
return user as UserAlreadyExist;
43+
return user;
4544
}
4645

4746
const sendEmailResult = await this.sendConfirmEmail({ id: user.id });
@@ -55,7 +54,7 @@ export class AuthServiceProvider {
5554
async signIn(payload: UserPayload) {
5655
const userResult = await this.userService.findVerifiedUser(payload);
5756
if (isError(userResult)) {
58-
return userResult as EmailOrPasswordIncorrect;
57+
return userResult;
5958
}
6059

6160
if (!userResult.emailConfirmed) {
@@ -82,7 +81,7 @@ export class AuthServiceProvider {
8281

8382
const userResult = await this.userService.findUser({ id: confirmEntityResult.userId });
8483
if (isError(userResult)) {
85-
return userResult as CannotFindUser;
84+
return userResult;
8685
}
8786

8887
if (userResult.emailConfirmed) {
@@ -91,7 +90,7 @@ export class AuthServiceProvider {
9190

9291
const confirmedResult = await this.userService.confirmEmail({ id: userResult.id });
9392
if (isError(confirmedResult)) {
94-
return confirmedResult as CannotFindUser;
93+
return confirmedResult;
9594
}
9695

9796
return this.generateTokensWithCookie(userResult.id, userResult.email);
@@ -100,7 +99,7 @@ export class AuthServiceProvider {
10099
async sendConfirmEmail(where: Pick<User, 'id'>) {
101100
const userResult = await this.userService.findUser(where);
102101
if (isError(userResult)) {
103-
return userResult as CannotFindUser;
102+
return userResult;
104103
}
105104

106105
if (userResult.emailConfirmed) {
@@ -134,7 +133,7 @@ export class AuthServiceProvider {
134133

135134
const user = await this.userService.findUser({ id });
136135
if (isError(user)) {
137-
return user as CannotFindUser;
136+
return user;
138137
}
139138

140139
if (user.refreshToken) {
@@ -163,7 +162,7 @@ export class AuthServiceProvider {
163162
const tokens = await this.generateTokens(id, email);
164163

165164
if (isError(tokens)) {
166-
return tokens as CannotFindUser;
165+
return tokens;
167166
}
168167

169168
return {

0 commit comments

Comments
 (0)