Skip to content

Commit

Permalink
fix: logout if user not found
Browse files Browse the repository at this point in the history
  • Loading branch information
cbartel-ci committed Dec 1, 2021
1 parent f9a37a5 commit 99e4d40
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
32 changes: 17 additions & 15 deletions server/src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,23 @@ export class UserService {
.then((permissions) => permissions.map((permission) => permission.permission));
}

async findUserWithPermissionsById(id: number): Promise<UserWithPermissions> {
return this.client.user
.findUnique({
where: { id },
include: {
UserPermission: true,
},
})
.then((result) => ({
id: result.id,
discordId: result.discordId,
discordUsername: result.discordUsername,
characterName: result.characterName,
permissions: result.UserPermission.map((it) => it.permission as Permission),
}));
async findUserWithPermissionsById(id: number): Promise<UserWithPermissions | undefined> {
const user = await this.client.user.findUnique({
where: { id },
include: {
UserPermission: true,
},
});
if (!user) {
return undefined;
}
return {
id: user.id,
discordId: user.discordId,
discordUsername: user.discordUsername,
characterName: user.characterName,
permissions: user.UserPermission.map((it) => it.permission as Permission),
};
}

async findByDiscordId(discordId: string): Promise<User> {
Expand Down
1 change: 1 addition & 0 deletions server/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ module.exports = function (options) {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
devtool: 'source-map',
};
};

0 comments on commit 99e4d40

Please sign in to comment.