refactor(passport): platform out of config

This commit is contained in:
cha0s 2024-01-28 12:32:46 -06:00
parent 3eb72c9ae1
commit 8962f53aba
3 changed files with 16 additions and 16 deletions

View File

@ -5,6 +5,20 @@ import {user, users} from './state';
export * from './state'; export * from './state';
export const hooks = { export const hooks = {
'@flecks/core.config': () => ({
/**
* Path to redirect to after failed login.
*/
failureRedirect: '/',
/**
* Path to redirect to after logout.
*/
logoutRedirect: '/',
/**
* Path to redirect to after successful login.
*/
successRedirect: '/',
}),
'@flecks/redux.slices': () => ({user, users}), '@flecks/redux.slices': () => ({user, users}),
'@flecks/socket.packets': Flecks.provide(require.context('./packets')), '@flecks/socket.packets': Flecks.provide(require.context('./packets')),
}; };

View File

@ -5,20 +5,6 @@ const debug = D('@flecks/passport');
const debugSilly = debug.extend('silly'); const debugSilly = debug.extend('silly');
export const hooks = { export const hooks = {
'@flecks/core.config': () => ({
/**
* Path to redirect to after failed login.
*/
failureRedirect: '/',
/**
* Path to redirect to after logout.
*/
logoutRedirect: '/',
/**
* Path to redirect to after successful login.
*/
successRedirect: '/',
}),
'@flecks/db.models': Flecks.provide(require.context('./models')), '@flecks/db.models': Flecks.provide(require.context('./models')),
'@flecks/socket.packets.decorate': Flecks.decorate(require.context('./packets/decorators')), '@flecks/socket.packets.decorate': Flecks.decorate(require.context('./packets/decorators')),
'@flecks/web/server.request.route': Flecks.priority( '@flecks/web/server.request.route': Flecks.priority(
@ -103,7 +89,7 @@ export const hooks = {
failureRedirect, failureRedirect,
logoutRedirect, logoutRedirect,
successRedirect, successRedirect,
} = flecks.get('@flecks/passport/server'); } = flecks.get('@flecks/passport');
const routes = [ const routes = [
{ {
method: 'get', method: 'get',

View File

@ -8,7 +8,7 @@ export default (Logout, flecks) => {
await new Promise((r, e) => { await new Promise((r, e) => {
req.session.save((error) => (error ? e(error) : r())); req.session.save((error) => (error ? e(error) : r()));
}); });
socket.send(['Redirect', flecks.get('@flecks/passport/server.logoutRedirect')]); socket.send(['Redirect', flecks.get('@flecks/passport.logoutRedirect')]);
} }
static validate(packet, {req}) { static validate(packet, {req}) {