T2951
Summary: Ref T2951 Test Plan: npm run test Reviewers: #testers, FilipI Reviewed By: FilipI Subscribers: FilipI, jenkins-user Maniphest Tasks: T2951 Differential Revision: https://hub.sealcode.org/D1526
This commit is contained in:
parent
3f09f26a31
commit
7488669b39
@ -86,7 +86,7 @@ describe("password-reset-intents", function () {
|
|||||||
(message) => message.recipients[0] == "<user@example.com>"
|
(message) => message.recipients[0] == "<user@example.com>"
|
||||||
);
|
);
|
||||||
assert.equal(messages.length, 1);
|
assert.equal(messages.length, 1);
|
||||||
assert.equal(messages[0].recipients.length, 1);
|
assert.equal(messages[0]?.recipients.length, 1);
|
||||||
assert.equal(messages[0].recipients[0], "<user@example.com>");
|
assert.equal(messages[0]?.recipients[0], "<user@example.com>");
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -23,6 +23,9 @@ export default class UserRoles extends Collection {
|
|||||||
await super.init(app, collection_name);
|
await super.init(app, collection_name);
|
||||||
app.on("started", async () => {
|
app.on("started", async () => {
|
||||||
const roles = app.collections["user-roles"];
|
const roles = app.collections["user-roles"];
|
||||||
|
if (!roles) {
|
||||||
|
throw new Error("roles undefined");
|
||||||
|
}
|
||||||
for (const action of <const>["create", "delete"]) {
|
for (const action of <const>["create", "delete"]) {
|
||||||
const policy = roles.getPolicy(action);
|
const policy = roles.getPolicy(action);
|
||||||
if (policy instanceof Policies.Public) {
|
if (policy instanceof Policies.Public) {
|
||||||
|
@ -42,6 +42,9 @@ export default class Users extends Collections.users {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async getRoles(ctx: Context) {
|
public static async getRoles(ctx: Context) {
|
||||||
|
if (!ctx.app.collections["user-roles"]) {
|
||||||
|
throw new Error("user-roles undefined");
|
||||||
|
}
|
||||||
const rolesEntries = await ctx.app.collections["user-roles"]
|
const rolesEntries = await ctx.app.collections["user-roles"]
|
||||||
.list(ctx)
|
.list(ctx)
|
||||||
.filter({ user: ctx.user_id || "" })
|
.filter({ user: ctx.user_id || "" })
|
||||||
|
@ -13,7 +13,9 @@ export default async function PasswordResetTemplate(
|
|||||||
if (!matching_users.items.length) {
|
if (!matching_users.items.length) {
|
||||||
throw new Errors.NotFound("No user with that email");
|
throw new Errors.NotFound("No user with that email");
|
||||||
}
|
}
|
||||||
|
if (!matching_users.items[0]) {
|
||||||
|
throw new Error("matching_users.items[0] undefined");
|
||||||
|
}
|
||||||
const username = matching_users.items[0].get("username");
|
const username = matching_users.items[0].get("username");
|
||||||
|
|
||||||
return EmailTemplates.Simple(app, {
|
return EmailTemplates.Simple(app, {
|
||||||
|
@ -12,6 +12,9 @@ export class Roles extends Policy {
|
|||||||
async countMatchingRoles(context: Context) {
|
async countMatchingRoles(context: Context) {
|
||||||
const user_id = context.user_id;
|
const user_id = context.user_id;
|
||||||
context.app.Logger.debug2("ROLES", "Checking the roles for user", user_id);
|
context.app.Logger.debug2("ROLES", "Checking the roles for user", user_id);
|
||||||
|
if (!context.app.collections["user-roles"]) {
|
||||||
|
throw new Error(`context.app.collections["user-roles"] undefined`);
|
||||||
|
}
|
||||||
const user_roles = await context.app.collections["user-roles"]
|
const user_roles = await context.app.collections["user-roles"]
|
||||||
.list(context)
|
.list(context)
|
||||||
.filter({ user: user_id })
|
.filter({ user: user_id })
|
||||||
|
@ -10,6 +10,10 @@ import { makeJDDContext } from "../../jdd-context.js";
|
|||||||
|
|
||||||
function moveElement<T>(array: Array<T>, fromIndex: number, toIndex: number): Array<T> {
|
function moveElement<T>(array: Array<T>, fromIndex: number, toIndex: number): Array<T> {
|
||||||
const element = array.splice(fromIndex, 1)[0];
|
const element = array.splice(fromIndex, 1)[0];
|
||||||
|
if (!element) {
|
||||||
|
console.error("element is undefined");
|
||||||
|
return array;
|
||||||
|
}
|
||||||
array.splice(toIndex, 0, element);
|
array.splice(toIndex, 0, element);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,9 @@ export const actionName = "Components";
|
|||||||
export default new (class JddcomponentDebuggerPage extends JDDPage {
|
export default new (class JddcomponentDebuggerPage extends JDDPage {
|
||||||
renderParameterButtons(state: JDDPageState): Stringifiable {
|
renderParameterButtons(state: JDDPageState): Stringifiable {
|
||||||
const all_components = super.getRegistryComponents();
|
const all_components = super.getRegistryComponents();
|
||||||
|
if (!state.components[0]) {
|
||||||
|
console.error("No components are present in state.components");
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<input type="submit" value="Preview" />
|
<input type="submit" value="Preview" />
|
||||||
@ -26,7 +29,11 @@ export default new (class JddcomponentDebuggerPage extends JDDPage {
|
|||||||
{Object.entries(all_components).map(([name]) => (
|
{Object.entries(all_components).map(([name]) => (
|
||||||
<option
|
<option
|
||||||
value={name}
|
value={name}
|
||||||
selected={name == state.components[0].component_name}
|
selected={
|
||||||
|
state.components[0]
|
||||||
|
? name == state.components[0].component_name
|
||||||
|
: false
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{name}
|
{name}
|
||||||
</option>
|
</option>
|
||||||
@ -40,7 +47,11 @@ export default new (class JddcomponentDebuggerPage extends JDDPage {
|
|||||||
actions = ComponentPreviewActions;
|
actions = ComponentPreviewActions;
|
||||||
|
|
||||||
async getInitialState(ctx: BaseContext) {
|
async getInitialState(ctx: BaseContext) {
|
||||||
const [component_name, component] = Object.entries(registry.getAll())[0];
|
const component_constants = Object.entries(registry.getAll())[0];
|
||||||
|
if (!component_constants) {
|
||||||
|
throw new Error("Constant component_name or component is udefined");
|
||||||
|
}
|
||||||
|
const [component_name, component] = component_constants;
|
||||||
const initial_state = {
|
const initial_state = {
|
||||||
components: [
|
components: [
|
||||||
{
|
{
|
||||||
|
@ -32,10 +32,12 @@ export function shuffle<T>(array: T[]): T[] {
|
|||||||
currentIndex--;
|
currentIndex--;
|
||||||
|
|
||||||
// And swap it with the current element.
|
// And swap it with the current element.
|
||||||
[array_copy[currentIndex], array_copy[randomIndex]] = [
|
const new_value = [array_copy[randomIndex], array_copy[currentIndex]];
|
||||||
array_copy[randomIndex],
|
if (new_value[0] && new_value[1]) {
|
||||||
array_copy[currentIndex],
|
[array_copy[currentIndex], array_copy[randomIndex]] = new_value;
|
||||||
];
|
} else {
|
||||||
|
console.error("One of array_copy's values is undefined");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return array_copy;
|
return array_copy;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
"noImplicitThis": true,
|
"noImplicitThis": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"target": "ES2019",
|
"target": "ES2019",
|
||||||
"esModuleInterop": true,
|
|
||||||
"lib": ["es2021"],
|
"lib": ["es2021"],
|
||||||
"outDir": "./dist/back",
|
"outDir": "./dist/back",
|
||||||
"keyofStringsOnly": true,
|
"keyofStringsOnly": true,
|
||||||
@ -18,7 +17,8 @@
|
|||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"esModuleInterop": true
|
"esModuleInterop": true,
|
||||||
|
"noUncheckedIndexedAccess": true
|
||||||
},
|
},
|
||||||
"include": ["./src/back/*", "./src/back/**/*", "./src/back/routes/common/navbar.ts"],
|
"include": ["./src/back/*", "./src/back/**/*", "./src/back/routes/common/navbar.ts"],
|
||||||
"exclude": ["./src/front", "./src/**/*.stimulus.ts"],
|
"exclude": ["./src/front", "./src/**/*.stimulus.ts"],
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
"target": "ES6",
|
"target": "ES6",
|
||||||
"lib": ["dom", "es2021"],
|
"lib": ["dom", "es2021"],
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"esModuleInterop": true
|
"esModuleInterop": true,
|
||||||
|
"noUncheckedIndexedAccess": true
|
||||||
},
|
},
|
||||||
"include": ["./src/front", "./src/**/*.stimulus.ts"]
|
"include": ["./src/front", "./src/**/*.stimulus.ts"]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user