UNPKG

stackpress

Version:

Incept is a content management framework.

41 lines (40 loc) 1.23 kB
export default async function SignupPage(req, res, ctx) { if (res.body || (res.code && res.code !== 200)) { return; } const view = ctx.config.path('view', {}); const brand = ctx.config.path('brand', {}); const auth = ctx.config.path('auth'); res.data.set('view', { base: view.base || '/', props: view.props || {} }); res.data.set('brand', { name: brand.name || 'Stackpress', logo: brand.logo || '/logo.png', icon: brand.icon || '/icon.png', favicon: brand.favicon || '/favicon.ico', }); res.data.set('auth', { base: auth.base || '/auth', roles: auth.roles || [], username: !!auth.username, email: !!auth.email, phone: !!auth.phone, password: auth.password || {} }); const redirect = req.data.path('redirect_uri', `${auth.base}/signin`); const session = ctx.plugin('session'); const me = session.load(req); const guest = await me.guest(); if (req.method === 'POST') { await ctx.emit('auth-signup', req, res); if (res.code === 200) { res.redirect(redirect); } } else if (!guest) { res.redirect(redirect); } } ;