Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7317099
password-reset-intents.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
password-reset-intents.ts
View Options
import
type
{
App
,
CollectionItem
,
Context
}
from
"sealious"
;
import
{
Collection
,
FieldTypes
,
Policies
}
from
"sealious"
;
import
assert
from
"assert"
;
import
PasswordResetTemplate
from
"../email-templates/password-reset.js"
;
import
TheApp
from
"../app.js"
;
import
{
assertType
,
predicates
}
from
"@sealcode/ts-predicates"
;
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
=
new
Policies
.
Super
();
async
init
(
app
:
App
,
name
:
string
)
{
assert
(
app
instanceof
TheApp
);
await
super
.
init
(
app
,
name
);
app
.
collections
[
"password-reset-intents"
].
on
(
"after:create"
,
async
([,
intent
]
:
[
Context
,
CollectionItem
<
PasswordResetIntents
>
,
unknown
])
=>
{
const
intent_as_super
=
await
intent
.
fetchAs
(
new
app
.
SuperContext
());
const
message
=
await
PasswordResetTemplate
(
app
,
{
email_address
:
assertType
(
intent
.
get
(
"email"
),
predicates
.
string
,
"email_address isn't a string"
),
token
:
assertType
(
intent_as_super
.
get
(
"token"
),
predicates
.
string
,
"token isn't a string"
),
});
await
message
.
send
(
app
);
}
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sun, Jul 13, 04:24 (16 h, 32 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
706346
Default Alt Text
password-reset-intents.ts (1 KB)
Attached To
Mode
rREWRITE Configurable rewriter
Attached
Detach File
Event Timeline
Log In to Comment