Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F5665673
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
,
_
,
params
)
=>
{
assert
(
params
.
token
,
"Token missing"
);
assert
(
params
.
username
,
"Username missing"
);
assert
(
params
.
password
,
"Password missing"
);
const
response
=
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"registration-intents"
],
"show"
,
{
filter
:
{
token
:
params
.
token
}
}
);
if
(
response
.
empty
)
{
throw
new
Error
(
"Incorrect token"
);
}
const
{
email
,
role
,
id
}
=
response
.
items
[
0
];
const
user
=
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"users"
],
"create"
,
{
password
:
params
.
password
,
username
:
params
.
username
,
email
,
}
);
if
(
role
)
{
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"user-roles"
],
"create"
,
{
user
:
user
.
id
,
role
}
);
}
await
app
.
run_action
(
new
app
.
Sealious
.
SuperContext
(),
[
"collections"
,
"registration-intents"
,
id
],
"delete"
);
const
target_path
=
app
.
ConfigManager
.
get
(
"accout_creation_success_path"
);
console
.
log
(
"TARGET PATH!:"
,
target_path
);
if
(
target_path
)
{
assert
.
equal
(
target_path
[
0
],
"/"
,
"'accout_creation_success_path' set, but doesn't start with a '/'"
);
return
`<meta http-equiv="refresh" content="0; url=
${
target_path
}
" />`
;
}
return
"Account creation successful"
;
}
);
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jun 7, 23:22 (15 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
730230
Default Alt Text
finalize-registration-intent.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment