Compare commits
No commits in common. "master" and "cambio-db" have entirely different histories.
@ -52,11 +52,6 @@ class Auth extends \Myth\Auth\Config\Auth
|
|||||||
'resend-activate-account' => 'resend-activate-account',
|
'resend-activate-account' => 'resend-activate-account',
|
||||||
'forgot' => 'forgot',
|
'forgot' => 'forgot',
|
||||||
'reset-password' => 'reset-password',
|
'reset-password' => 'reset-password',
|
||||||
|
|
||||||
// ADMIN AUTH
|
|
||||||
// 'custom_route' => 'custom_route',
|
|
||||||
'admin_login' => 'admin_login',
|
|
||||||
'admin_logout' => 'admin_logout',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Config;
|
namespace Config;
|
||||||
|
|
||||||
use App\Filters\AdminFilter;
|
|
||||||
use App\Filters\FormularioInicialFilter;
|
use App\Filters\FormularioInicialFilter;
|
||||||
use App\Filters\InicioFilter;
|
use App\Filters\InicioFilter;
|
||||||
use CodeIgniter\Config\BaseConfig;
|
use CodeIgniter\Config\BaseConfig;
|
||||||
@ -30,7 +29,6 @@ class Filters extends BaseConfig
|
|||||||
'role' => \Myth\Auth\Filters\RoleFilter::class,
|
'role' => \Myth\Auth\Filters\RoleFilter::class,
|
||||||
'inicio' => InicioFilter::class,
|
'inicio' => InicioFilter::class,
|
||||||
'formulario_inicial' => FormularioInicialFilter::class,
|
'formulario_inicial' => FormularioInicialFilter::class,
|
||||||
'admin_filter' => AdminFilter::class,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +42,7 @@ class Filters extends BaseConfig
|
|||||||
// 'honeypot',
|
// 'honeypot',
|
||||||
// 'csrf',
|
// 'csrf',
|
||||||
// 'invalidchars',
|
// 'invalidchars',
|
||||||
// 'login'
|
'login'
|
||||||
],
|
],
|
||||||
'after' => [
|
'after' => [
|
||||||
'toolbar',
|
'toolbar',
|
||||||
@ -80,8 +78,7 @@ class Filters extends BaseConfig
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $filters = [
|
public $filters = [
|
||||||
'login' => ['before' => ['/', 'registro/', 'encuesta/*']],
|
'inicio' => ['before' => ['/',]],
|
||||||
'inicio' => ['before' => ['/']],
|
'formulario_inicial' => ['before' => ['registro/']]
|
||||||
'formulario_inicial' => ['before' => ['registro/']],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -49,19 +49,13 @@ $routes->post('encuesta/submit/(:segment)', 'Encuesta::submit/$1', ['as' => 'enc
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// utilizar método attemptRegister personalizdo (no requiere de username)
|
// utilizar m<EFBFBD>todo attemptRegister personalizdo (no requiere de username)
|
||||||
$routes->post('register/', 'Auth::attemptRegister');
|
$routes->post('register/', 'Auth::attemptRegister');
|
||||||
|
// $routes->post('login/', 'Auth::attemptLogin');
|
||||||
|
|
||||||
// ADMIN AUTH
|
$routes->group('admin', ['filter' => 'role:Admin'], static function ($routes) {
|
||||||
$routes->match(['get', 'post'], 'admin/login/', 'AdminAuth::login', ['as' => 'admin_login']);
|
|
||||||
$routes->get('admin/logout', 'AdminAuth::logout', ['as' => 'admin_logout']);
|
|
||||||
|
|
||||||
$routes->group('admin', ['filter' => 'admin_filter'], static function ($routes) {
|
|
||||||
$routes->get('/', 'Admin::home', ['as' => 'admin_home']);
|
$routes->get('/', 'Admin::home', ['as' => 'admin_home']);
|
||||||
|
|
||||||
// PRESTADORES
|
|
||||||
$routes->get('prestadores/', 'Admin::prestadores', ['as' => 'admin_prestadores']);
|
|
||||||
|
|
||||||
// SOLICITUDES
|
// SOLICITUDES
|
||||||
$routes->get('solicitudes/', 'Admin::solicitudes', ['as' => 'admin_solicitudes']);
|
$routes->get('solicitudes/', 'Admin::solicitudes', ['as' => 'admin_solicitudes']);
|
||||||
$routes->post('solicitud/rechazar/(:segment)', 'Admin::rechazarSolicitud/$1', ['as' => 'admin_solicitud_rechazar']);
|
$routes->post('solicitud/rechazar/(:segment)', 'Admin::rechazarSolicitud/$1', ['as' => 'admin_solicitud_rechazar']);
|
||||||
|
@ -21,13 +21,6 @@ class Admin extends BaseController
|
|||||||
return view('Admin/index', $data);
|
return view('Admin/index', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PRESTADORES
|
|
||||||
public function prestadores()
|
|
||||||
{
|
|
||||||
$prestadores = model(PrestadorModel::class)->getPrestadoresActivos();
|
|
||||||
// dd($prestadores[0]);
|
|
||||||
return view('Admin/prestadores', ['prestadores' => $prestadores]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// SOLICITUDES
|
// SOLICITUDES
|
||||||
public function solicitudes()
|
public function solicitudes()
|
||||||
@ -65,6 +58,8 @@ class Admin extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function aprobarSolicitud($id)
|
public function aprobarSolicitud($id)
|
||||||
{
|
{
|
||||||
$solicitudModel = model(ModelsPrestadorSolicitudModel::class);
|
$solicitudModel = model(ModelsPrestadorSolicitudModel::class);
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controllers;
|
|
||||||
|
|
||||||
use App\Controllers\BaseController;
|
|
||||||
use App\Models\UsuarioModel;
|
|
||||||
|
|
||||||
class AdminAuth extends BaseController
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
public function login()
|
|
||||||
{
|
|
||||||
if ($this->request->getMethod() === 'post') {
|
|
||||||
$rules = [
|
|
||||||
'nombreusuario' => 'required',
|
|
||||||
'password' => 'required',
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!$this->validate($rules)) {
|
|
||||||
return redirect()->back()->with('msg', array(
|
|
||||||
'type' => 'danger',
|
|
||||||
'body' => 'Es necesario llenar todos los campos'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// obtener datos
|
|
||||||
$data = $this->request->getPost();
|
|
||||||
|
|
||||||
|
|
||||||
// Buscar usuario
|
|
||||||
if (!$usuario = model(UsuarioModel::class)->findByUsername($data['nombreusuario'])) {
|
|
||||||
return redirect()->back()->with('msg', array(
|
|
||||||
'type' => 'danger',
|
|
||||||
'body' => 'Revisa tus credenciales e inténtalo nuevamente'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verificar contraseña
|
|
||||||
if (!password_verify($data['password'], $usuario['password'])) {
|
|
||||||
return redirect()->back()->with('msg', array(
|
|
||||||
'type' => 'danger',
|
|
||||||
'body' => 'Revisa tus credenciales e inténtalo nuevamente'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inicializar sesión
|
|
||||||
session()->set([
|
|
||||||
'id' => $usuario['idusuario'],
|
|
||||||
'usuario' => $usuario['nombreusuario'],
|
|
||||||
'is_logged' => true,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return redirect()->route('admin_home')->with('msg', array(
|
|
||||||
'type' => 'success',
|
|
||||||
'body' => 'Inicio de sesión correcto'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return view('AdminAuth/login');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function logout()
|
|
||||||
{
|
|
||||||
$session = session();
|
|
||||||
$session->remove(['id', 'usuario', 'is_logged']);
|
|
||||||
return redirect()->route('admin_login');
|
|
||||||
}
|
|
||||||
}
|
|
@ -35,7 +35,7 @@ abstract class BaseController extends Controller
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $helpers = ['auth', 'session'];
|
protected $helpers = ['auth'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filters;
|
|
||||||
|
|
||||||
use CodeIgniter\Filters\FilterInterface;
|
|
||||||
use CodeIgniter\HTTP\RequestInterface;
|
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
|
||||||
|
|
||||||
class AdminFilter implements FilterInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Do whatever processing this filter needs to do.
|
|
||||||
* By default it should not return anything during
|
|
||||||
* normal execution. However, when an abnormal state
|
|
||||||
* is found, it should return an instance of
|
|
||||||
* CodeIgniter\HTTP\Response. If it does, script
|
|
||||||
* execution will end and that Response will be
|
|
||||||
* sent back to the client, allowing for error pages,
|
|
||||||
* redirects, etc.
|
|
||||||
*
|
|
||||||
* @param RequestInterface $request
|
|
||||||
* @param array|null $arguments
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function before(RequestInterface $request, $arguments = null)
|
|
||||||
{
|
|
||||||
$session = session();
|
|
||||||
$loggedIn = $session->is_logged;
|
|
||||||
if (!$loggedIn) {
|
|
||||||
return redirect()->route('admin_login');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows After filters to inspect and modify the response
|
|
||||||
* object as needed. This method does not allow any way
|
|
||||||
* to stop execution of other after filters, short of
|
|
||||||
* throwing an Exception or Error.
|
|
||||||
*
|
|
||||||
* @param RequestInterface $request
|
|
||||||
* @param ResponseInterface $response
|
|
||||||
* @param array|null $arguments
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
@ -27,13 +27,6 @@ class PrestadorModel extends Model
|
|||||||
return $this->where('idprestador', $id)->first();
|
return $this->where('idprestador', $id)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPrestadoresActivos()
|
|
||||||
{
|
|
||||||
return $this
|
|
||||||
->where('status', 0)
|
|
||||||
->findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
function countPrestadoresActivos()
|
function countPrestadoresActivos()
|
||||||
{
|
{
|
||||||
return $this
|
return $this
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use CodeIgniter\Model;
|
|
||||||
|
|
||||||
class UsuarioModel extends Model
|
|
||||||
{
|
|
||||||
protected $table = 'usuarios';
|
|
||||||
protected $primaryKey = 'idusuario';
|
|
||||||
protected $useAutoIncrement = true;
|
|
||||||
protected $insertID = 0;
|
|
||||||
protected $returnType = 'array';
|
|
||||||
protected $useSoftDeletes = false;
|
|
||||||
protected $protectFields = true;
|
|
||||||
protected $allowedFields = [];
|
|
||||||
|
|
||||||
|
|
||||||
public function findByUsername($username)
|
|
||||||
{
|
|
||||||
return $this->where('nombreusuario', $username)->first();
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,7 +29,7 @@
|
|||||||
<div class="icon">
|
<div class="icon">
|
||||||
<i class="fas fa-user-check"></i>
|
<i class="fas fa-user-check"></i>
|
||||||
</div>
|
</div>
|
||||||
<a href="<?= route_to('admin_prestadores') ?>" class="small-box-footer">
|
<a href="#" class="small-box-footer">
|
||||||
Ver lista <i class="fas fa-arrow-circle-right"></i>
|
Ver lista <i class="fas fa-arrow-circle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
<?= $this->extend('templates/baseAdmin') ?>
|
|
||||||
|
|
||||||
<?= $this->section('content') ?>
|
|
||||||
|
|
||||||
<h2>lista de prestadores</h2>
|
|
||||||
|
|
||||||
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
|
|
||||||
<script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
|
|
||||||
<script src="https://cdn.datatables.net/1.12.1/js/dataTables.bootstrap5.min.js"></script>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
|
|
||||||
<table id="table-solicitudes" class="table table-bordered table-striped">
|
|
||||||
<thead>
|
|
||||||
<th>Nombre</th>
|
|
||||||
<th>Tipo</th>
|
|
||||||
<th>Email</th>
|
|
||||||
<th>Celular</th>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
<?php foreach ($prestadores as $prestador) : ?>
|
|
||||||
<tr>
|
|
||||||
<td><?= $prestador['nombre'] . ' ' . $prestador['apaterno'] . ' ' . $prestador['amaterno'] ?></td>
|
|
||||||
<td><?= $prestador['tipo'] ?></td>
|
|
||||||
<td><?= $prestador['email'] ?></td>
|
|
||||||
<td><?= $prestador['celular'] ?></td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach ?>
|
|
||||||
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
let table = new DataTable('#table-solicitudes', {
|
|
||||||
'searching': true,
|
|
||||||
'ordering': true,
|
|
||||||
'language': {
|
|
||||||
"decimal": "",
|
|
||||||
"emptyTable": "No hay información",
|
|
||||||
"info": "Mostrando _START_ a _END_ de _TOTAL_ registros",
|
|
||||||
"infoEmpty": "Mostrando 0 to 0 of 0 registros",
|
|
||||||
"infoFiltered": "(Filtrado de _MAX_ total registros)",
|
|
||||||
"infoPostFix": "",
|
|
||||||
"thousands": ",",
|
|
||||||
"lengthMenu": "Mostrar _MENU_ registros",
|
|
||||||
"loadingRecords": "Cargando...",
|
|
||||||
"processing": "Procesando...",
|
|
||||||
"search": "Buscar:",
|
|
||||||
"zeroRecords": "No se encontraron resultados",
|
|
||||||
"paginate": {
|
|
||||||
"first": "Primero",
|
|
||||||
"last": "Ultimo",
|
|
||||||
"next": "Siguiente",
|
|
||||||
"previous": "Anterior"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'order': [],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
|
@ -1,41 +0,0 @@
|
|||||||
<?= $this->extend('templates/baseAdmin') ?>
|
|
||||||
|
|
||||||
<?= $this->section('content') ?>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="card">
|
|
||||||
<h2 class="card-header"><?= lang('Auth.loginTitle') ?></h2>
|
|
||||||
<div class="card-body">
|
|
||||||
|
|
||||||
<?= view('Myth\Auth\Views\_message_block') ?>
|
|
||||||
|
|
||||||
<form action="<?= route_to('admin_login') ?>" method="post">
|
|
||||||
<?= csrf_field() ?>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="nombreusuario">Usuario</label>
|
|
||||||
<input type="text" class="form-control <?php if (session('errors.nombreusuario')) : ?>is-invalid<?php endif ?>" name="nombreusuario" placeholder="Usuario">
|
|
||||||
<div class="invalid-feedback">
|
|
||||||
<?= session('errors.nombreusuario') ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="password"><?= lang('Auth.password') ?></label>
|
|
||||||
<input type="password" name="password" class="form-control <?php if (session('errors.password')) : ?>is-invalid<?php endif ?>" placeholder="<?= lang('Auth.password') ?>">
|
|
||||||
<div class="invalid-feedback">
|
|
||||||
<?= session('errors.password') ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary btn-block"><?= lang('Auth.loginAction') ?></button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
|
@ -38,8 +38,6 @@ scratch. This page gets rid of all links and provides the needed markup only.
|
|||||||
|
|
||||||
<!-- Sidebar Menu -->
|
<!-- Sidebar Menu -->
|
||||||
<nav class="mt-2">
|
<nav class="mt-2">
|
||||||
<?php $session = session();
|
|
||||||
if ($session->is_logged) : ?>
|
|
||||||
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
|
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
|
||||||
<!-- Add icons to the links using the .nav-icon class
|
<!-- Add icons to the links using the .nav-icon class
|
||||||
with font-awesome or any other icon font library -->
|
with font-awesome or any other icon font library -->
|
||||||
@ -51,7 +49,7 @@ scratch. This page gets rid of all links and provides the needed markup only.
|
|||||||
</a>
|
</a>
|
||||||
<ul class="nav nav-treeview">
|
<ul class="nav nav-treeview">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="<?= route_to('admin_prestadores') ?>" class="nav-link">
|
<a href="#" class="nav-link">
|
||||||
<i class="far fa-circle nav-icon"></i>
|
<i class="far fa-circle nav-icon"></i>
|
||||||
Activos
|
Activos
|
||||||
</a>
|
</a>
|
||||||
@ -87,15 +85,7 @@ scratch. This page gets rid of all links and provides the needed markup only.
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
|
||||||
<a href="<?= route_to('admin_logout') ?>" class="nav-link">
|
|
||||||
<i class="nav-icon fas fa-sign-out-alt"></i>
|
|
||||||
Cerrar sesión
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<!-- /.sidebar-menu -->
|
<!-- /.sidebar-menu -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user