UNPKG

stackpress

Version:

Incept is a content management framework.

41 lines (40 loc) 1.19 kB
export default async function SignInPage(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_uri: redirect = '/' } = req.data(); const session = ctx.plugin('session'); const { guest } = session.load(req); if (req.method === 'POST') { await ctx.emit('auth-signin', req, res); if (res.code !== 200) return; res.redirect(redirect); return; } else if (!guest) { res.redirect(redirect); } } ;