Page MenuHomeSealhub

password-reset-intents.ts
No OneTemporary

password-reset-intents.ts

import PasswordResetTemplate from "../../email/templates/password-reset";
import {
App,
Collection,
CollectionItem,
Context,
FieldTypes,
Policies,
} from "../../main";
export default class PasswordResetIntents extends Collection {
name = "password-reset-intents";
fields = {
email: new FieldTypes.ValueExistingInCollection({
field: "email",
collection: "users",
include_forbidden: true,
}),
token: new FieldTypes.SecretToken(),
};
policies = {
create: new Policies.Public(),
edit: new Policies.Noone(),
};
defaultPolicy: Policies.Super;
async init(app: App, name: string) {
await super.init(app, name);
app.collections["password-reset-intents"].on(
"after:create",
async ([context, intent]: [
Context,
CollectionItem<PasswordResetIntents>,
any
]) => {
const intent_as_super = await intent.fetchAs(
new app.SuperContext()
);
const message = await PasswordResetTemplate(app, {
email_address: intent.get("email"),
token: intent_as_super.get("token"),
});
await message.send(app);
}
);
}
}

File Metadata

Mime Type
text/x-java
Expires
Sat, Nov 1, 16:05 (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1004257
Default Alt Text
password-reset-intents.ts (1 KB)

Event Timeline