Skip to content

Commit

Permalink
fix: omit user passwords from locals
Browse files Browse the repository at this point in the history
  • Loading branch information
aalemayhu committed Dec 8, 2024
1 parent 7f7b0f5 commit ad763f6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/controllers/UsersControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getRedirect } from './helpers/getRedirect';
import { getIndexFileContents } from './IndexController/getIndexFileContents';
import { getRandomUUID } from '../shared/helpers/getRandomUUID';
import { getDefaultAvatarPicture } from '../lib/getDefaultAvatarPicture';
import Users from '../data_layer/public/Users';

class UsersController {
constructor(
Expand Down Expand Up @@ -168,8 +169,8 @@ class UsersController {

async getLocals(_req: express.Request, res: express.Response) {
const { locals } = res;
let user = {};
let linkedEmail;
let user: Users | undefined;
let linkedEmail: string | null = null;

if (res.locals.owner) {
user = await this.userService.getUserById(res.locals.owner);
Expand All @@ -178,7 +179,17 @@ class UsersController {
);
}

return res.json({ user, locals, linked_email: linkedEmail });
return res.json({
user: {
id: user?.id,
name: user?.name,
patreon: user?.patreon,
picture: user?.picture,
email: user?.email,
},
locals,
linked_email: linkedEmail,
});
}

async linkEmail(req: express.Request, res: express.Response) {
Expand Down

0 comments on commit ad763f6

Please sign in to comment.