Skip to content
This repository has been archived by the owner on Sep 23, 2022. It is now read-only.

Commit

Permalink
fix(deps): update prisma to v1.33.0 (#197)
Browse files Browse the repository at this point in the history
* chore(deps): update prismagraphql/prisma docker tag to v1.33.0

* fix(deps): update dependency prisma to v1.33.0 (#196)

* fix(deps): unique constraints query in prisma 1.33
  • Loading branch information
renovate[bot] authored and pvtri96 committed May 19, 2019
1 parent 2a1ea09 commit 10059da
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 65 deletions.
2 changes: 1 addition & 1 deletion compose/docker-compose.db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"
services:
prisma:
container_name: re-radio_prisma
image: prismagraphql/prisma:1.32.2
image: prismagraphql/prisma:1.33.0
restart: "no"
depends_on: [db]
environment:
Expand Down
118 changes: 59 additions & 59 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"passport": "0.4.0",
"passport-http-bearer": "1.0.1",
"passport-jwt": "4.0.0",
"prisma": "1.32.2",
"prisma": "1.33.0",
"prisma-binding": "2.3.10",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.2",
Expand Down
15 changes: 11 additions & 4 deletions server/src/radio/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,27 @@ export class AuthService {

async validateUserFromJWTPayload(payload: JwtPayload): Promise<User> {
const { username, email, password } = payload;
let users: User[];
try {
const user = await this.prisma.query.user(
users = await this.prisma.query.users(
{ where: { username, email } },
`{
id createdAt updatedAt email username password name country city bio avatarUrl coverUrl reputation facebookId googleId
password
roles { id role }
}`,
);
if (user.password !== password) throw new UnauthorizedException();
return user;
} catch (error) {
throw new UnauthorizedException();
throw new UnauthorizedException(error.message);
}
if (users.length === 0) {
throw new UnauthorizedException('User not found');
}
if (users.length > 1)
throw new InternalServerErrorException('JWT is broken due to duplicated query results for 1 unique user');
const [user] = users;
if (user.password !== password) throw new UnauthorizedException();
return user;
}

private async generateUsername(email: string) {
Expand Down

0 comments on commit 10059da

Please sign in to comment.