2023-03-03 15:54:28 +00:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Inertia Preloaded File
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Any code written inside this file will be executed during the application
|
|
|
|
| boot.
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Inertia from '@ioc:EidelLev/Inertia';
|
|
|
|
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
|
|
|
|
|
|
|
Inertia.share({
|
|
|
|
errors: (ctx) => {
|
|
|
|
return ctx.session.flashMessages.get('errors');
|
|
|
|
},
|
|
|
|
|
|
|
|
flash: (ctx) => {
|
|
|
|
return {
|
|
|
|
message: ctx.session.flashMessages.get('message'),
|
2023-07-17 17:13:30 +00:00
|
|
|
warning: ctx.session.flashMessages.get('warning'),
|
2023-03-03 15:54:28 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
// params: ({ params }) => params,
|
2023-11-27 16:17:22 +00:00
|
|
|
authUser: async ({ auth }: HttpContextContract) => {
|
2023-03-03 15:54:28 +00:00
|
|
|
if (auth.user) {
|
2023-11-27 16:17:22 +00:00
|
|
|
await auth.user.load('roles');
|
2023-03-03 15:54:28 +00:00
|
|
|
return auth.user;
|
|
|
|
// {
|
|
|
|
// 'id': auth.user.id,
|
|
|
|
// 'login': auth.user.login,
|
|
|
|
// };
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}).version(() => Inertia.manifestFile('public/assets/manifest.json'));
|
|
|
|
|
|
|
|
// 'flash' => [
|
|
|
|
// 'message' => fn () => $request->session()->get('message'),
|
|
|
|
// ],
|