Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996345
finalize-registration-intent.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-registration-intent.js
View Options
const
assert
=
require
(
"assert"
);
module
.
exports
=
app
=>
{
app
.
WwwServer
.
custom_route
(
"POST"
,
"/finalize-registration-intent"
,
async
(
app
,
context
,
params
)
=>
{
assert
(
params
.
token
,
"Token missing"
);
assert
(
params
.
username
,
"Username missing"
);
assert
(
params
.
password
,
"Password missing"
);
const
{
items
:
matches
}
=
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"registration-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
intent
=
matches
[
0
];
const
user
=
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"users"
],
"create"
,
{
password
:
params
.
password
,
username
:
params
.
username
,
email
:
intent
.
body
.
email
,
}
);
if
(
intent
.
body
.
role
)
{
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"user-roles"
],
"create"
,
{
user
:
user
.
id
,
role
:
intent
.
body
.
role
}
);
}
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"registration-intents"
,
matches
[
0
].
id
],
"delete"
);
return
"Account creation successful"
;
}
);
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 14:02 (21 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557195
Default Alt Text
finalize-registration-intent.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment