Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3893786
finalize-registration-intent.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
finalize-registration-intent.ts
View Options
import
assert
from
"assert"
;
import
{
App
}
from
"../../main"
;
export
default
(
app
:
App
)
=>
{
app
.
HTTPServer
.
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
intents
=
await
app
.
collections
[
"registration-intents"
]
.
suList
()
.
filter
({
token
:
params
.
token
})
.
fetch
();
if
(
intents
.
empty
)
{
throw
new
Error
(
"Incorrect token"
);
}
const
intent
=
intents
.
items
[
0
];
const
user
=
await
app
.
collections
.
users
.
suCreate
({
password
:
params
.
password
,
username
:
params
.
username
,
email
:
intent
.
get
(
"email"
),
roles
:
[],
});
if
(
intent
.
get
(
"role"
))
{
await
app
.
collections
[
"user-roles"
].
suCreate
({
user
:
user
.
id
,
role
:
intent
.
get
(
"role"
),
});
}
await
intent
.
remove
(
new
app
.
SuperContext
());
const
target_path
=
app
.
ConfigManager
.
get
(
"accout_creation_success_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/x-java
Expires
Mon, May 19, 00:55 (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
663360
Default Alt Text
finalize-registration-intent.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment