Skip to content

Commit

Permalink
added missing lastPasswordChangedAt property
Browse files Browse the repository at this point in the history
  • Loading branch information
larryrider committed Nov 9, 2023
1 parent 3633951 commit 61c0647
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/app/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export class AuthController {
backupsBucket: userData.backupsBucket,
avatar: userData.avatar ? await this.service.User.getSignedAvatarUrl(userData.avatar) : null,
emailVerified: userData.emailVerified,
lastPasswordChangedAt: userData.lastPasswordChangedAt,
};

const userTeam = null;
Expand Down
1 change: 1 addition & 0 deletions src/app/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default (router: Router, service: any, App: any): Router => {
backupsBucket: userData.backupsBucket,
avatar: userData.avatar ? await service.User.getSignedAvatarUrl(userData.avatar) : null,
emailVerified: userData.emailVerified,
lastPasswordChangedAt: userData.lastPasswordChangedAt,
};

res.status(200).json({ user, token });
Expand Down
9 changes: 7 additions & 2 deletions src/app/routes/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import {
FileAlreadyExistsError,
FileWithNameAlreadyExistsError
} from '../services/errors/FileWithNameAlreadyExistsError';
import { FolderAlreadyExistsError, FolderWithNameAlreadyExistsError } from '../services/errors/FolderWithNameAlreadyExistsError';
import {
FolderAlreadyExistsError,
FolderWithNameAlreadyExistsError
} from '../services/errors/FolderWithNameAlreadyExistsError';
import * as resourceSharingMiddlewareBuilder from '../middleware/resource-sharing.middleware';
import {validate } from 'uuid';

Expand Down Expand Up @@ -94,7 +97,9 @@ export class StorageController {
return res.status(409).send({ error: err.message });
}
this.logger.error(
`[FILE/CREATE] ERROR: ${(err as Error).message}, BODY ${JSON.stringify(file)}, STACK: ${(err as Error).stack} USER: ${behalfUser.email}`,
`[FILE/CREATE] ERROR: ${(err as Error).message}, BODY ${
JSON.stringify(file)
}, STACK: ${(err as Error).stack} USER: ${behalfUser.email}`,
);
res.status(500).send({ error: 'Internal Server Error' });
}
Expand Down
3 changes: 2 additions & 1 deletion src/config/initializers/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ module.exports = (App, Config) => {
.then((user) => {
const userWithoutLastPasswordChangedAt = user.lastPasswordChangedAt === null;
const userWithLastPasswordChangedAtLowerThanToken =
user.lastPasswordChangedAt && Math.floor(new Date(user.lastPasswordChangedAt).getTime()) / 1000 < payload.iat;
user.lastPasswordChangedAt &&
Math.floor(new Date(user.lastPasswordChangedAt).getTime()) / 1000 < payload.iat;
if (userWithoutLastPasswordChangedAt || userWithLastPasswordChangedAtLowerThanToken) {
done(null, user);
} else {
Expand Down

0 comments on commit 61c0647

Please sign in to comment.