From 9e8533ea50207370219437c07f58a4e03164297e Mon Sep 17 00:00:00 2001 From: Aldarien Date: Fri, 10 Apr 2020 15:22:00 -0400 Subject: [PATCH] Mejoras a administracion --- bootstrap/web/config.php | 7 +++++-- bootstrap/web/setup.php | 1 + common/Service/Login.php | 5 +++-- provm/common/Service/Filemanager.php | 4 ++-- resources/data/login.yml | 4 ++-- resources/views/admin/admin.blade.php | 2 +- resources/views/admin/clave.blade.php | 2 +- resources/views/admin/layout/base.blade.php | 13 +++++-------- resources/views/admin/layout/body.blade.php | 10 ++++++++++ resources/views/admin/layout/header.blade.php | 5 +++++ resources/views/admin/layout/menu.blade.php | 15 +++++++-------- resources/views/admin/login.blade.php | 2 +- 12 files changed, 43 insertions(+), 27 deletions(-) create mode 100644 resources/views/admin/layout/body.blade.php create mode 100644 resources/views/admin/layout/header.blade.php diff --git a/bootstrap/web/config.php b/bootstrap/web/config.php index 0c43ce1..4084fa6 100644 --- a/bootstrap/web/config.php +++ b/bootstrap/web/config.php @@ -90,9 +90,12 @@ return [ 'app.cookie.name' => 'login', 'app.cookie.time' => 20 * 60 * 60, // 20 min 'files.login' => 'login.yml', - 'urls.login' => DI\string(implode('/', [ + 'urls.admin' => DI\string(implode('/', [ '{urls.base}', - 'admin', + 'admin' + ])), + 'urls.login' => DI\string(implode('/', [ + '{urls.admin}', 'login' ])) ]; diff --git a/bootstrap/web/setup.php b/bootstrap/web/setup.php index ea9f2fd..799af8c 100644 --- a/bootstrap/web/setup.php +++ b/bootstrap/web/setup.php @@ -43,6 +43,7 @@ return [ return new ProVM\NotariaRaby\Common\Service\Login( $c->get('app.cookie.name'), $c->get('app.cookie.time'), + $c->get('urls.admin'), getenv('ADMIN_PASSWORD'), $c->get('files.login'), $c->get(ProVM\Common\Service\Filemanager::class) diff --git a/common/Service/Login.php b/common/Service/Login.php index 27ac031..ff8f2a2 100644 --- a/common/Service/Login.php +++ b/common/Service/Login.php @@ -11,8 +11,9 @@ class Login { protected $password; protected $filename; protected $manager; - public function __construct(string $cookie_name, int $time_limit, string $encrypted_password, string $login_file, Filemanager $filemanager) { + public function __construct(string $cookie_name, int $time_limit, string $base_url, string $encrypted_password, string $login_file, Filemanager $filemanager) { $this->cookie_name = $cookie_name; + $this->base_url = $base_url; $this->time_limit = $time_limit; $this->password = $encrypted_password; $this->filename = $login_file; @@ -31,7 +32,7 @@ class Login { public function saveCookie() { $now = Carbon::now(); $exp = $now->addSeconds($this->time_limit); - \setcookie($this->cookie_name, implode(':', [$this->selector, $this->token]), $exp->timestamp, '/'); + \setcookie($this->cookie_name, implode(':', [$this->selector, $this->token]), $exp->timestamp, $this->base_url); } public function removeCookie() { \setcookie($this->cookie_name, '', Carbon::now()->timestamp, '/'); diff --git a/provm/common/Service/Filemanager.php b/provm/common/Service/Filemanager.php index d00883b..be085c7 100644 --- a/provm/common/Service/Filemanager.php +++ b/provm/common/Service/Filemanager.php @@ -70,7 +70,7 @@ class Filemanager { } return $temp; } - public function save(string $filename, $data) { + public function save(string $filename, $data): bool { if (is_object($data)) { $data = (array) $data; } @@ -78,6 +78,6 @@ class Filemanager { $data = Yaml::YAMLDump($data, false, false, true); } $filename = $this->fullPath($filename); - file_put_contents($filename, $data); + return file_put_contents($filename, $data); } } diff --git a/resources/data/login.yml b/resources/data/login.yml index d5b4add..4c06be7 100644 --- a/resources/data/login.yml +++ b/resources/data/login.yml @@ -1,4 +1,4 @@ ip: localhost token: > - 2c579161cd33d9b2d3dd7791:b6936fbd9f2f1403558af3e5bc5330188af9a03e -time: 2020-04-07 16:20 + 4b2910b375e3ae3ff415b8ad:80dbbc8862d0bf7d45155a982a6721d768596a0a +time: 2020-04-10 16:17 diff --git a/resources/views/admin/admin.blade.php b/resources/views/admin/admin.blade.php index 27e6ef4..8a65c77 100644 --- a/resources/views/admin/admin.blade.php +++ b/resources/views/admin/admin.blade.php @@ -1,6 +1,6 @@ @extends('admin.layout.base') -@section('content') +@section('page_content')
diff --git a/resources/views/admin/clave.blade.php b/resources/views/admin/clave.blade.php index 9ecfbaf..b92dd70 100644 --- a/resources/views/admin/clave.blade.php +++ b/resources/views/admin/clave.blade.php @@ -1,6 +1,6 @@ @extends('admin.layout.base') -@section('content') +@section('page_content')

Cambiar Clave

diff --git a/resources/views/admin/layout/base.blade.php b/resources/views/admin/layout/base.blade.php index 126eac2..52792dd 100644 --- a/resources/views/admin/layout/base.blade.php +++ b/resources/views/admin/layout/base.blade.php @@ -1,12 +1,9 @@ -@extends('layout.base') + + +@include('layout.head') +@include('admin.layout.body') + @section('page_title') - Admin @endsection - -@section('page_content') -
-
- @yield('content') -
-@endsection diff --git a/resources/views/admin/layout/body.blade.php b/resources/views/admin/layout/body.blade.php new file mode 100644 index 0000000..c824271 --- /dev/null +++ b/resources/views/admin/layout/body.blade.php @@ -0,0 +1,10 @@ + +
+ @include('admin.layout.header') +
+
+ @yield('page_content') +
+ @include('layout.footer') +
+ diff --git a/resources/views/admin/layout/header.blade.php b/resources/views/admin/layout/header.blade.php new file mode 100644 index 0000000..a618c50 --- /dev/null +++ b/resources/views/admin/layout/header.blade.php @@ -0,0 +1,5 @@ +
+
+ @include('admin.layout.menu') +
+
diff --git a/resources/views/admin/layout/menu.blade.php b/resources/views/admin/layout/menu.blade.php index d03decf..55abdbc 100644 --- a/resources/views/admin/layout/menu.blade.php +++ b/resources/views/admin/layout/menu.blade.php @@ -1,8 +1,7 @@ - -
+ diff --git a/resources/views/admin/login.blade.php b/resources/views/admin/login.blade.php index 029ac69..ae8651b 100644 --- a/resources/views/admin/login.blade.php +++ b/resources/views/admin/login.blade.php @@ -1,6 +1,6 @@ @extends('admin.layout.base') -@section('content') +@section('page_content')