Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996429
finalize-password-reset.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
finalize-password-reset.js
View Options
const
assert
=
require
(
"assert"
);
module
.
exports
=
app
=>
{
app
.
WwwServer
.
custom_route
(
"POST"
,
"/finalize-password-reset"
,
async
(
app
,
context
,
params
)
=>
{
assert
(
params
.
token
,
"Token missing"
);
assert
(
params
.
password
,
"Password missing"
);
const
{
items
:
matches
}
=
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"password-reset-intents"
],
"show"
,
{
filter
:
{
token
:
params
.
token
}
}
);
if
(
matches
.
length
===
0
)
{
throw
new
Error
(
"Incorrect token"
);
}
else
if
(
matches
.
length
>
1
)
{
throw
new
Error
(
"Something went wrong."
);
}
const
user_email
=
matches
[
0
].
email
;
const
{
items
:
[
user
],
}
=
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"users"
],
"show"
,
{
filter
:
{
email
:
user_email
}
}
);
if
(
!
user
)
{
throw
new
Error
(
"No user with this email address."
);
}
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"users"
,
user
.
id
],
"edit"
,
{
password
:
params
.
password
}
);
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"password-reset-intents"
,
matches
[
0
].
id
],
"delete"
);
return
"Password reset successful"
;
}
);
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 14:03 (18 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557254
Default Alt Text
finalize-password-reset.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment