Cli user
This commit is contained in:
10
app/resources/routes/96_admin.php
Normal file
10
app/resources/routes/96_admin.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$app->group('/admin', function($app) {
|
||||
$files = new FilesystemIterator(implode(DIRECTORY_SEPARATOR, [__DIR__, 'admin']));
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
});
|
6
app/resources/routes/admin/users.php
Normal file
6
app/resources/routes/admin/users.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Admin\Users;
|
||||
|
||||
$app->group('/users', function($app) {
|
||||
$app->get('[/]', Users::class);
|
||||
});
|
13
app/resources/routes/api/admin.php
Normal file
13
app/resources/routes/api/admin.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
$app->group('/admin', function($app) {
|
||||
$folder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'admin']);
|
||||
if (file_exists($folder)) {
|
||||
$files = new FilesystemIterator($folder);
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
include_once $file->getRealPath();
|
||||
}
|
||||
}
|
||||
});
|
6
app/resources/routes/api/admin/users.php
Normal file
6
app/resources/routes/api/admin/users.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Admin\Users;
|
||||
|
||||
$app->group('/users', function($app) {
|
||||
$app->post('/add[/]', Users::class . ':add');
|
||||
});
|
4
app/resources/routes/api/login.php
Normal file
4
app/resources/routes/api/login.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Login;
|
||||
|
||||
$app->post('/login[/]', Login::class);
|
@ -4,6 +4,10 @@ use Incoviba\Controller\API\Money;
|
||||
$app->group('/money', function($app) {
|
||||
$app->post('/ipc[/]', [Money::class, 'ipc']);
|
||||
$app->post('/uf[/]', [Money::class, 'uf']);
|
||||
$app->group('/ufs', function($app) {
|
||||
$app->post('[/]', [Money::class, 'updateUfs']);
|
||||
$app->get('[/]', [Money::class, 'ufs']);
|
||||
});
|
||||
$app->post('/many[/]', [Money::class, 'getMany']);
|
||||
$app->post('[/]', [Money::class, 'get']);
|
||||
});
|
||||
|
100
app/resources/views/admin/users.blade.php
Normal file
100
app/resources/views/admin/users.blade.php
Normal file
@ -0,0 +1,100 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">Usuarios</h2>
|
||||
<table class="ui table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nombre</th>
|
||||
<th class="right aligned">
|
||||
<button class="ui mini green icon button" id="create-user-button">
|
||||
<i class="plus icon"></i>
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($users as $user)
|
||||
<tr>
|
||||
<td>{{ $user->name }}</td>
|
||||
<td class="right aligned">
|
||||
<button class="ui mini blue icon button">
|
||||
<i class="edit icon"></i>
|
||||
</button>
|
||||
<button class="ui mini red icon button">
|
||||
<i class="trash icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui modal" id="create-user-modal">
|
||||
<i class="close icon"></i>
|
||||
<div class="header">
|
||||
Crear usuario
|
||||
</div>
|
||||
<div class="content">
|
||||
<form class="ui form">
|
||||
<div class="field">
|
||||
<label>Nombre</label>
|
||||
<input type="text" name="name" placeholder="Nombre">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Correo</label>
|
||||
<input type="email" name="email" placeholder="Correo">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Contraseña</label>
|
||||
<input type="password" name="password" placeholder="Contraseña">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<div class="ui black deny button">
|
||||
Cancelar
|
||||
</div>
|
||||
<div class="ui positive right labeled icon button">
|
||||
Crear
|
||||
<i class="checkmark icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include('layout.body.scripts.cryptojs')
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
function encryptPassword(password) {
|
||||
const passphrase = Math.floor(Math.random() * Date.now()).toString()
|
||||
const encrypted = CryptoJS.AES.encrypt(password, passphrase)
|
||||
return [passphrase, encrypted.toString()].join('')
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$('#create-user-modal').modal({
|
||||
onApprove: function() {
|
||||
const url = '{{$urls->api}}/admin/users/add'
|
||||
const method = 'post'
|
||||
const body = new FormData(document.querySelector('#create-user-modal form'))
|
||||
body.set('password', encryptPassword(body.get('password')))
|
||||
fetchAPI(url, {method, body}).then(response => {
|
||||
if (!response) {
|
||||
return;
|
||||
}
|
||||
response.json().then(result => {
|
||||
if (result.success) {
|
||||
location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
$('#create-user-button').on('click', function () {
|
||||
$('#create-user-modal').modal('show')
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@endpush
|
Reference in New Issue
Block a user