stackpress
Version:
Incept is a content management framework.
43 lines (42 loc) • 2.19 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = AuthSignup;
const actions_js_1 = require("../actions.js");
function AuthSignup(req, res, ctx) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c;
const roles = ctx.config.path('session.auth.roles', []);
const engine = ctx.plugin('database');
const client = ctx.plugin('client');
const seed = ctx.config.path('database.seed', 'abc123');
const input = Object.assign({ roles }, req.data());
const response = yield (0, actions_js_1.signup)(input, seed, engine, client);
if (response.code === 200) {
if (input.email) {
ctx.resolve('email-email-send', Object.assign({ email: input.email }, response.results));
}
if (input.phone) {
ctx.resolve('auth-phone-verify', Object.assign({ phone: input.phone }, response.results));
}
}
if ((_a = response.results) === null || _a === void 0 ? void 0 : _a.auth.email) {
delete response.results.auth.email.secret;
}
if ((_b = response.results) === null || _b === void 0 ? void 0 : _b.auth.phone) {
delete response.results.auth.phone.secret;
}
if ((_c = response.results) === null || _c === void 0 ? void 0 : _c.auth.username) {
delete response.results.auth.username.secret;
}
res.fromStatusResponse(response);
});
}