UNPKG

stackpress

Version:

Incept is a content management framework.

25 lines (24 loc) 851 B
import { signin } from '../actions'; export default async function AuthSignin(req, res, ctx) { const type = req.data('type') || 'username'; const engine = ctx.plugin('database'); const client = ctx.plugin('client'); const seed = ctx.config.path('session.seed', 'abc123'); const response = await signin(type, req.data(), seed, engine, client); if (response.results) { const results = response.results; delete results.secret; } res.fromStatusResponse(response); if (response.code !== 200) { return; } const registry = ctx.plugin('session'); const results = response.results; res.session.set(registry.key, registry.create({ id: results.profile.id, name: results.profile.name, image: results.profile.image, roles: results.profile.roles })); }