Skip to content
This repository was archived by the owner on Jul 25, 2021. It is now read-only.

Commit b27dec1

Browse files
authored
fix: User.password no longer selected by default (#61)
* done? * tests passing, changed query * linting issues * more linting fixes * more linting fixes * new query * revert
1 parent 343530d commit b27dec1

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/entities/User.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class User {
4444
@MaxLength(40, { message: 'Surname must be between 1 to 40 characters long' })
4545
public surname!: string;
4646

47-
@Column()
47+
@Column({ select: false })
4848
public password!: string;
4949

5050
@Column({ unique: true })

src/services/UserService.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import sharp from 'sharp';
1313
const writeFile = promisify(_writeFile);
1414
const unlink = promisify(_unlink);
1515

16+
1617
export type UserDataToCreate = Pick<User, 'forename' | 'surname' | 'email' | 'password'>;
1718
export type ProfileDataToCreate = Omit<Profile, 'id' | 'user' | 'toJSON' | 'avatar'> & { avatar: string|boolean };
1819

@@ -105,7 +106,11 @@ export class UserService {
105106
throw new APIError(HttpCode.BadRequest, AuthenticateError.AccountNotFound);
106107
}
107108

108-
const user = await getRepository(User).findOne({ email });
109+
const user = await getRepository(User)
110+
.createQueryBuilder('user').where('user.email= :email', { email })
111+
.addSelect('user.password')
112+
.getOne();
113+
109114
if (!user) {
110115
throw new APIError(HttpCode.BadRequest, AuthenticateError.AccountNotFound);
111116
}

0 commit comments

Comments
 (0)