Changeset View
Changeset View
Standalone View
Standalone View
lib/http/routes/finalize-registration-intent.js
Show All 21 Lines | async (app, context, params) => { | ||||
const intent = matches[0]; | const intent = matches[0]; | ||||
const user = await app.run_action( | const user = await app.run_action( | ||||
new app.Sealious.SuperContext(), | new app.Sealious.SuperContext(), | ||||
["collections", "users"], | ["collections", "users"], | ||||
"create", | "create", | ||||
{ | { | ||||
password: params.password, | password: params.password, | ||||
username: params.username, | username: params.username, | ||||
email: intent.body.email, | email: intent.email, | ||||
} | } | ||||
); | ); | ||||
if (intent.body.role) { | if (intent.role) { | ||||
await app.run_action( | await app.run_action( | ||||
new app.Sealious.SuperContext(), | new app.Sealious.SuperContext(), | ||||
["collections", "user-roles"], | ["collections", "user-roles"], | ||||
"create", | "create", | ||||
{ user: user.id, role: intent.body.role } | { user: user.id, role: intent.role } | ||||
); | ); | ||||
} | } | ||||
await app.run_action( | await app.run_action( | ||||
new app.Sealious.SuperContext(), | new app.Sealious.SuperContext(), | ||||
["collections", "registration-intents", matches[0].id], | ["collections", "registration-intents", matches[0].id], | ||||
"delete" | "delete" | ||||
); | ); | ||||
return "Account creation successful"; | return "Account creation successful"; | ||||
} | } | ||||
); | ); | ||||
}; | }; |