-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into pix-16318-fix-mastery-rate-display
- Loading branch information
Showing
51 changed files
with
1,234 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
api/db/migrations/20250129071223_add-has-embed-internal-validation-to-challenges.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const SCHEMA_NAME = 'learningcontent'; | ||
const TABLE_NAME = 'challenges'; | ||
const COLUMN_NAME = 'hasEmbedInternalValidation'; | ||
|
||
const up = async function (knex) { | ||
await knex.schema.withSchema(SCHEMA_NAME).table(TABLE_NAME, function (table) { | ||
table | ||
.boolean(COLUMN_NAME) | ||
.defaultTo(false) | ||
.comment('Indicates that the embed has internal rules to handle the challenge validation'); | ||
}); | ||
}; | ||
|
||
const down = async function (knex) { | ||
await knex.schema.withSchema(SCHEMA_NAME).table(TABLE_NAME, function (table) { | ||
table.dropColumn(COLUMN_NAME); | ||
}); | ||
}; | ||
|
||
export { down, up }; |
22 changes: 22 additions & 0 deletions
22
api/db/migrations/20250129071224_add-no-validation-needed-to-challenges.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const SCHEMA_NAME = 'learningcontent'; | ||
const TABLE_NAME = 'challenges'; | ||
const COLUMN_NAME = 'noValidationNeeded'; | ||
|
||
const up = async function (knex) { | ||
await knex.schema.withSchema(SCHEMA_NAME).table(TABLE_NAME, function (table) { | ||
table | ||
.boolean(COLUMN_NAME) | ||
.defaultTo(false) | ||
.comment( | ||
'Indicates that the challenge does not need any validation, i.e. contains only a video to watch or a text to read', | ||
); | ||
}); | ||
}; | ||
|
||
const down = async function (knex) { | ||
await knex.schema.withSchema(SCHEMA_NAME).table(TABLE_NAME, function (table) { | ||
table.dropColumn(COLUMN_NAME); | ||
}); | ||
}; | ||
|
||
export { down, up }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
api/src/identity-access-management/domain/models/RevokedUserAccess.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export class RevokedUserAccess { | ||
constructor(revokeTimeStamp) { | ||
this.revokeTimeStamp = revokeTimeStamp; | ||
} | ||
isAccessTokenRevoked(decodedToken) { | ||
const issuedAt = decodedToken.iat; | ||
if (!this.revokeTimeStamp) { | ||
return false; | ||
} | ||
return issuedAt < this.revokeTimeStamp; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
.../identity-access-management/infrastructure/repositories/revoked-user-access.repository.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { config } from '../../../../src/shared/config.js'; | ||
import { temporaryStorage } from '../../../../src/shared/infrastructure/key-value-storages/index.js'; | ||
import { UserIdIsRequiredError } from '../../domain/errors.js'; | ||
import { RevokeUntilMustBeAnInstanceOfDate } from '../../domain/errors.js'; | ||
import { RevokedUserAccess } from '../../domain/models/RevokedUserAccess.js'; | ||
|
||
const revokedUserAccessTemporaryStorage = temporaryStorage.withPrefix('revoked-user-access:'); | ||
const revokedUserAccessLifespanMs = config.authentication.revokedUserAccessLifespanMs; | ||
|
||
const saveForUser = async function (userId, revokeUntil) { | ||
if (!userId) { | ||
throw new UserIdIsRequiredError(); | ||
} | ||
|
||
if (!(revokeUntil instanceof Date)) { | ||
throw new RevokeUntilMustBeAnInstanceOfDate(); | ||
} | ||
|
||
await revokedUserAccessTemporaryStorage.save({ | ||
key: userId, | ||
value: Math.floor(revokeUntil.getTime() / 1000), | ||
expirationDelaySeconds: revokedUserAccessLifespanMs / 1000, | ||
}); | ||
}; | ||
|
||
const findByUserId = async function (userId) { | ||
const value = await revokedUserAccessTemporaryStorage.get(userId); | ||
return new RevokedUserAccess(value); | ||
}; | ||
|
||
export const revokedUserAccessRepository = { saveForUser, findByUserId }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.