create login page
This commit is contained in:
parent
6b31d89e1d
commit
5b3549068b
6 changed files with 88 additions and 42 deletions
|
|
@ -1,27 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return function ($page, $kirby, $site) {
|
return function ($page, $kirby, $site) {
|
||||||
if (!$kirby->user()) {
|
if (!$kirby->user() && $page->uri() != 'login') {
|
||||||
go($site->panel()->url());
|
go('/login');
|
||||||
}
|
} else {
|
||||||
$data = $page->toArray();
|
$data = $page->toArray();
|
||||||
$data['template'] = (string) $page->template();
|
$data['template'] = (string) $page->template();
|
||||||
$data['newInspirations'] = (bool) page('inspirations')->children()->findBy('new', 'true');
|
$data['newInspirations'] = (bool) page('inspirations')->children()->findBy('new', 'true');
|
||||||
|
|
||||||
$userData = [
|
if ($kirby->user()) {
|
||||||
"role" => (string) $kirby->user()->role(),
|
$userData = [
|
||||||
"uuid" => (string) $kirby->user()->uuid()
|
"role" => (string) $kirby->user()->role(),
|
||||||
];
|
"uuid" => (string) $kirby->user()->uuid()
|
||||||
|
];
|
||||||
if ($kirby->user()->client()->exists() && $kirby->user()->client()->isNotEmpty()) {
|
|
||||||
$userData['client'] = [
|
if ($kirby->user()->client()->exists() && $kirby->user()->client()->isNotEmpty()) {
|
||||||
"name" => (string) $kirby->user()->client()->toPage()->title(),
|
$userData['client'] = [
|
||||||
"uuid" => (string) $kirby->user()->client()->toPage()->uuid()
|
"name" => (string) $kirby->user()->client()->toPage()->title(),
|
||||||
|
"uuid" => (string) $kirby->user()->client()->toPage()->uuid()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return [
|
||||||
|
'genericData' => $data,
|
||||||
|
'userData' => $userData ?? null
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
|
||||||
'genericData' => $data,
|
|
||||||
'userData' => $userData
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
13
public/site/templates/login.json.php
Normal file
13
public/site/templates/login.json.php
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$specificData = [
|
||||||
|
"exampleField" => $page->exampleField(),
|
||||||
|
"exampleHardData" => 'Example hard value'
|
||||||
|
];
|
||||||
|
|
||||||
|
$pageData = array_merge($genericData, $specificData);
|
||||||
|
|
||||||
|
echo json_encode([
|
||||||
|
"page" => $pageData,
|
||||||
|
"user" => $userData
|
||||||
|
]);
|
||||||
1
public/site/templates/login.php
Normal file
1
public/site/templates/login.php
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
<?php snippet('generic-template') ?>
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<h1 v-if="page" class="sr-only">{{ page.content.title }}</h1>
|
<h1 v-if="page" class="sr-only">{{ page.content.title }}</h1>
|
||||||
<div class="with-sidebar">
|
<div :class="{ 'with-sidebar': page?.template !== 'login' }">
|
||||||
<Menu />
|
<Menu v-if="page?.template !== 'login'" />
|
||||||
<RouterView />
|
<RouterView />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -1,60 +1,65 @@
|
||||||
import Home from "../views/Home.vue";
|
import Home from '../views/Home.vue';
|
||||||
import Notifications from "../views/Notifications.vue";
|
import Notifications from '../views/Notifications.vue';
|
||||||
import Reunions from "../views/Reunions.vue";
|
import Reunions from '../views/Reunions.vue';
|
||||||
import Inspirations from "../views/Inspirations.vue";
|
import Inspirations from '../views/Inspirations.vue';
|
||||||
import Kanban from "../views/Kanban.vue";
|
import Kanban from '../views/Kanban.vue';
|
||||||
import Brief from "../views/Brief.vue";
|
import Brief from '../views/Brief.vue';
|
||||||
import DesignToLight from "../views/DesignToLight.vue";
|
import DesignToLight from '../views/DesignToLight.vue';
|
||||||
|
import Login from '../views/Login.vue';
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
path: "/",
|
path: '/',
|
||||||
component: Home,
|
component: Home,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/notifications",
|
path: '/login',
|
||||||
|
component: Login,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/notifications',
|
||||||
component: Notifications,
|
component: Notifications,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/reunions",
|
path: '/reunions',
|
||||||
component: Reunions,
|
component: Reunions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/inspirations",
|
path: '/inspirations',
|
||||||
component: Inspirations,
|
component: Inspirations,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/design-to-light",
|
path: '/design-to-light',
|
||||||
component: DesignToLight,
|
component: DesignToLight,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/projects/:id",
|
path: '/projects/:id',
|
||||||
component: Kanban,
|
component: Kanban,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/projects/:id/client-brief",
|
path: '/projects/:id/client-brief',
|
||||||
component: Brief,
|
component: Brief,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/projects/:id/extended-brief",
|
path: '/projects/:id/extended-brief',
|
||||||
component: Brief,
|
component: Brief,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Redirections
|
// Redirections
|
||||||
{
|
{
|
||||||
path: "/projects/:id/industrial-ideation",
|
path: '/projects/:id/industrial-ideation',
|
||||||
redirect: (to) => {
|
redirect: (to) => {
|
||||||
return (
|
return (
|
||||||
"/projects/" +
|
'/projects/' +
|
||||||
to.params.id +
|
to.params.id +
|
||||||
"?dialog=industrial-ideation&comments=true"
|
'?dialog=industrial-ideation&comments=true'
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/projects/:id/proposal",
|
path: '/projects/:id/proposal',
|
||||||
redirect: (to) => {
|
redirect: (to) => {
|
||||||
return "/projects/" + to.params.id + "?dialog=proposal&comments=true";
|
return '/projects/' + to.params.id + '?dialog=proposal&comments=true';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
||||||
23
src/views/Login.vue
Normal file
23
src/views/Login.vue
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<template>
|
||||||
|
<form
|
||||||
|
@submit.prevent="handleSubmit"
|
||||||
|
class="w-full h-full p-16 flex flex-col"
|
||||||
|
style="--row-gap: 1rem"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="subject"
|
||||||
|
id="appointment-subject"
|
||||||
|
placeholder="Objet du rendez-vous"
|
||||||
|
class="w-full rounded-md border border-grey-200 px-16 py-12"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<label for="appointment-details" class="sr-only">Détails du projet</label>
|
||||||
|
<button @click="login" class="btn" type="submit">Soumettre</button>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
function login() {
|
||||||
|
console.log('test');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue