Login validation, user profile icon

This commit is contained in:
Deon George 2020-09-15 22:40:32 +10:00
parent c549d28340
commit db61e0d1ce
9 changed files with 119 additions and 66 deletions

View File

@ -30,6 +30,7 @@ Some of the creations planned to be used in v2 include:
* JQuery (https://jquery.com) * JQuery (https://jquery.com)
* FancyTree (https://github.com/mar10/fancytree) * FancyTree (https://github.com/mar10/fancytree)
* ArchitectUI (https://architectui.com) * ArchitectUI (https://architectui.com)
* Fontawesome Icons (https://fontawesome.com)
PLA v1.2.x will be archived into [BRANCH-1.2](https://github.com/leenooks/phpLDAPadmin/tree/BRANCH-1.2), and `master` will be changed to reflect the new v2 work and effort. PLA v1.2.x will be archived into [BRANCH-1.2](https://github.com/leenooks/phpLDAPadmin/tree/BRANCH-1.2), and `master` will be changed to reflect the new v2 work and effort.

View File

@ -3,9 +3,12 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\Crypt;
use App\Classes\LDAP\Server; use App\Classes\LDAP\Server;
use Illuminate\Support\Facades\File;
class HomeController extends Controller class HomeController extends Controller
{ {
@ -32,4 +35,29 @@ class HomeController extends Controller
->with('dn',$dn) ->with('dn',$dn)
->with('leaf',(new Server())->fetch($dn)); ->with('leaf',(new Server())->fetch($dn));
} }
/**
* Return the image for the logged in user or anonymous
*
* @param Request $request
* @return mixed
*/
public function user_image(Request $request)
{
$image = NULL;
$content = NULL;
if (Auth::check()) {
$image = Arr::get(Auth::user()->getAttribute('jpegphoto'),0);
$content = 'image/jpeg';
}
if (! $image) {
$image = File::get('../resources/images/user-secret-solid.svg');
$content = 'image/svg+xml';
}
return response($image)
->header('Content-Type',$content);
}
} }

View File

@ -0,0 +1 @@
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="user-secret" class="svg-inline--fa fa-user-secret fa-w-14" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M383.9 308.3l23.9-62.6c4-10.5-3.7-21.7-15-21.7h-58.5c11-18.9 17.8-40.6 17.8-64v-.3c39.2-7.8 64-19.1 64-31.7 0-13.3-27.3-25.1-70.1-33-9.2-32.8-27-65.8-40.6-82.8-9.5-11.9-25.9-15.6-39.5-8.8l-27.6 13.8c-9 4.5-19.6 4.5-28.6 0L182.1 3.4c-13.6-6.8-30-3.1-39.5 8.8-13.5 17-31.4 50-40.6 82.8-42.7 7.9-70 19.7-70 33 0 12.6 24.8 23.9 64 31.7v.3c0 23.4 6.8 45.1 17.8 64H56.3c-11.5 0-19.2 11.7-14.7 22.3l25.8 60.2C27.3 329.8 0 372.7 0 422.4v44.8C0 491.9 20.1 512 44.8 512h358.4c24.7 0 44.8-20.1 44.8-44.8v-44.8c0-48.4-25.8-90.4-64.1-114.1zM176 480l-41.6-192 49.6 32 24 40-32 120zm96 0l-32-120 24-40 49.6-32L272 480zm41.7-298.5c-3.9 11.9-7 24.6-16.5 33.4-10.1 9.3-48 22.4-64-25-2.8-8.4-15.4-8.4-18.3 0-17 50.2-56 32.4-64 25-9.5-8.8-12.7-21.5-16.5-33.4-.8-2.5-6.3-5.7-6.3-5.8v-10.8c28.3 3.6 61 5.8 96 5.8s67.7-2.1 96-5.8v10.8c-.1.1-5.6 3.2-6.4 5.8z"></path></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -5,33 +5,23 @@
@endsection @endsection
@section('content') @section('content')
@if(isset($login_note) AND $login_note)
<div class="alert alert-info alert-dismissible m-auto">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<h5><i class="icon fas fa-info"></i> NOTE!</h5>
{!! $login_note !!}
</div>
<br>
@endisset
@if (Session::has('error'))
<div class="alert alert-danger">
<strong>Hmm...</strong> {{ trans('message.someproblems') }}<br><br>
<ul>
<li>{{ Session::get('error') }}</li>
</ul>
</div>
@endif
<!-- /.login-logo --> <!-- /.login-logo -->
<div class="app-container app-theme-white body-tabs-shadow"> <div class="app-container app-theme-white body-tabs-shadow">
<div class="app-container"> <div class="app-container">
<div class="h-100 bg-animation"> <div class="h-100 bg-animation">
<div class="d-flex h-100 justify-content-center align-items-center"> <div class="d-flex h-100 justify-content-center align-items-center">
<div class="mx-auto app-login-box col-md-8"> <div class="mx-auto app-login-box col-md-8">
@if(asset('login-note.txt'))
<div class="mx-auto card text-white card-body bg-primary w-50">
<h5 class="text-white card-title"><i class="icon fa-2x fas fa-info pr-3"></i><span class="font-size-xlg">NOTE</span></h5>
<span class="w-100 pb-0">
{!! file_get_contents('login-note.txt') !!}
</span>
</div>
@endif
<div class="modal-dialog w-100 mx-auto"> <div class="modal-dialog w-100 mx-auto">
<div class="modal-content"> <div class="modal-content">
<form method="post"> <form class="needs-validation" novalidate method="post">
{{ csrf_field() }} {{ csrf_field() }}
<div class="modal-body"> <div class="modal-body">
@ -43,22 +33,24 @@
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="col-md-12"> <div class="col-md-12 mt-3">
<div class="position-relative form-group"> <label class="mb-1">Email</label>
<input name="email" id="user" placeholder="Email..." type="email" class="form-control"> <input name="email" id="user" placeholder="" type="email" class="form-control" required="">
<div class="invalid-feedback">
Please enter your email.
</div> </div>
</div> </div>
<div class="col-md-12">
<div class="position-relative form-group"> <div class="col-md-12 mt-2">
<input name="password" id="password" placeholder="Password..." type="password" class="form-control"> <label class="mb-1">Password</label>
<input name="password" id="password" placeholder="" type="password" class="form-control" required>
<div class="invalid-feedback">
Please enter your password.
</div> </div>
</div> </div>
</div> </div>
{{--
<div class="divider"></div>
<h6 class="mb-0">No account? <a href="javascript:void(0);" class="text-primary">Sign up now</a></h6>
--}}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@if (count($errors) > 0) @if (count($errors) > 0)
<div class="alert alert-danger w-100"> <div class="alert alert-danger w-100">
@ -70,11 +62,6 @@
</ul> </ul>
</div> </div>
@endif @endif
{{--
<div class="float-left">
<a href="javascript:void(0);" class="btn-lg btn btn-link">Recover Password</a>
</div>
--}}
<div class="float-right"> <div class="float-right">
<button class="btn btn-primary btn-lg">Login</button> <button class="btn btn-primary btn-lg">Login</button>
</div> </div>
@ -88,3 +75,39 @@
</div> </div>
</div> </div>
@endsection @endsection
@section('page-scripts')
<style>
label {
text-transform: uppercase;
letter-spacing: 0.05em;
font-size: 85%;
font-weight: bold;
}
table.table tr:last-child {
border-bottom: 1px solid #e9ecef;
}
</style>
<script>
// Example starter JavaScript for disabling form submissions if there are invalid fields
(function () {
'use strict';
window.addEventListener('load',function () {
// Fetch all the forms we want to apply custom Bootstrap validation styles to
var forms = document.getElementsByClassName('needs-validation');
// Loop over them and prevent submission
var validation = Array.prototype.filter.call(forms, function (form) {
form.addEventListener('submit', function (event) {
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
});
}, false);
})();
</script>
@append

View File

@ -11,6 +11,8 @@
@section('scripts') @section('scripts')
@include('architect::auth.partials.scripts') @include('architect::auth.partials.scripts')
@yield('page-scripts')
@show @show
</body> </body>
</html> </html>

View File

@ -1,7 +1,4 @@
<script src="{{ asset('/js/app.js') }}" type="text/javascript"></script> <script src="{{ asset('/js/app.js') }}" type="text/javascript"></script>
{{--
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
--}}
<!-- Architect --> <!-- Architect -->
<script src="{{ asset('/js/architect.min.js') }}"></script> <script src="{{ asset('/js/architect.min.js') }}"></script>

View File

@ -54,35 +54,34 @@
<div class="header-btn-lg pr-0"> <div class="header-btn-lg pr-0">
<div class="widget-content p-0"> <div class="widget-content p-0">
<div class="widget-content-wrapper"> <div class="widget-content-wrapper">
<div class="widget-content-left"> <div class="widget-content-left ml-3 header-user-info">
<div class="btn-group">
<a data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="p-0 btn">
<img width="42" class="rounded-circle" src="assets/images/avatars/1.jpg" alt="">
<i class="fas fa-angle-down ml-2 opacity-8"></i>
</a>
<div tabindex="-1" role="menu" aria-hidden="true" class="dropdown-menu dropdown-menu-right">
{{--
<button type="button" tabindex="0" class="dropdown-item">User Account</button>
<h6 tabindex="-1" class="dropdown-header">Header</h6>
<button type="button" tabindex="0" class="dropdown-item">Actions</button>
<div tabindex="-1" class="dropdown-divider"></div>
<button type="button" tabindex="0" class="dropdown-item">Dividers</button>
--}}
</div>
</div>
</div>
<div class="widget-content-left ml-3 header-user-info">
<div class="widget-heading"> <div class="widget-heading">
{{ $user->name ?? 'John Smith' }} {{ $user->exists ? Arr::get($user->getAttribute('cn'),0,'Anonymous') : 'Anonymous' }}
</div> </div>
<div class="widget-subheading"> <div class="widget-subheading">
{{ $user->title ?? 'Primary Developer' }} {{ $user->exists ? Arr::get($user->getAttribute('mail'),0,'') : '' }}
</div> </div>
</div> </div>
<div class="widget-content-right header-user-info ml-3"> <div class="widget-content-right">
<button type="button" class="btn-shadow p-1 btn btn-primary btn-sm show-toastr-example"> <div class="btn-group">
<i class="fas text-white fa-calendar pr-1 pl-1"></i> <a data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="p-0 btn">
</button> <i class="fas fa-angle-down ml-2 opacity-8"></i>
<img width="35" height="35" class="rounded" src="{{ url('user/image') }}" alt="" style="background-color: #eee;padding: 2px;">
</a>
<div tabindex="-1" role="menu" aria-hidden="true" class="dropdown-menu dropdown-menu-right">
@if ($user->exists)
<h6 tabindex="-1" class="dropdown-header text-center">User Menu</h6>
<div tabindex="-1" class="dropdown-divider"></div>
<a href="{{ url('logout') }}" tabindex="0" class="dropdown-item">
<i class="fas fa-fw fa-sign-out-alt mr-2"></i> Sign Out
</a>
@else
<a href="{{ url('login') }}" tabindex="0" class="dropdown-item">
<i class="fas fa-fw fa-sign-in-alt mr-2"></i> Sign In
</a>
@endif
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -14,12 +14,10 @@ use Illuminate\Support\Facades\Route;
| |
*/ */
/*
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
*/
Route::group([],function() { Route::group([],function() {
Route::get('/bases','APIController@bases'); Route::get('/bases','APIController@bases');
Route::get('/children','APIController@children'); Route::get('/children','APIController@children');
}); });
Route::group(['middleware'=>'auth:api','prefix'=>'user'],function() {
});

View File

@ -24,3 +24,7 @@ Route::redirect('/','home');
Route::get('logout','Auth\LoginController@logout'); Route::get('logout','Auth\LoginController@logout');
Route::get('home','HomeController@home'); Route::get('home','HomeController@home');
Route::post('render','HomeController@render'); Route::post('render','HomeController@render');
Route::group(['prefix'=>'user'],function() {
Route::get('image','HomeController@user_image');
});