Skip to content

Commit

Permalink
Adding password resets
Browse files Browse the repository at this point in the history
Also fixing and refactoring stuff like translations, modals...
  • Loading branch information
arcanedev-maroc committed Oct 30, 2016
1 parent 3c59f9b commit 34cc619
Show file tree
Hide file tree
Showing 47 changed files with 661 additions and 86 deletions.
10 changes: 10 additions & 0 deletions config/sidebar/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,15 @@
Policies\PermissionsPolicy::PERMISSION_LIST,
],
],
[
'title' => 'Password Resets',
'name' => 'auth-password-resets',
'route' => 'auth::foundation.password-resets.index',
'icon' => 'fa fa-fw fa-refresh',
'roles' => [Role::ADMINISTRATOR],
'permissions' => [
Policies\PasswordResetsPolicy::PERMISSION_LIST,
],
],
],
];
2 changes: 1 addition & 1 deletion resources/lang/en/password.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'register' => 'Don\'t have an account ? Sign up',
],
'mail' => [
'subject' => 'Reset Password - ' . config('app.name'),
'subject' => 'Reset Password - :name',
'line-1' => 'You are receiving this email because we received a password reset request for your account.',
'line-2' => 'If you did not request a password reset, no further action is required.',
'action' => 'Reset Password',
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/fr/password.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'register' => 'Vous n\'avez pas un compte? Inscrivez-vous',
],
'mail' => [
'subject' => 'Réinitialiser votre mot de passe - ' . config('app.name'),
'subject' => 'Réinitialiser votre mot de passe - :name',
'line-1' => 'Vous recevez ce courriel parce que nous avons reçu une demande de réinitialisation de mot de passe pour votre compte.',
'line-2' => 'Si vous ne l\'avez pas demandé une réinitialisation de mot de passe, aucune autre action est nécessaire.',
'action' => 'Réinitialiser le mot de passe',
Expand Down
207 changes: 207 additions & 0 deletions resources/views/foundation/password-resets/list.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
@section('header')
<h1><i class="fa fa-fw fa-refresh"></i> Password Resets <small>List of password resets</small></h1>
@endsection

@section('content')
<div class="box box-success">
<div class="box-header with-border">
<span class="label label-info" style="margin-right: 5px;">
Total : {{ $resets->total() }}
</span>
@if ($resets->hasPages())
<span class="label label-info">
{{ trans('foundation::pagination.pages', ['current' => $resets->currentPage(), 'last' => $resets->lastPage()]) }}
</span>
@endif
<div class="box-tools">
<a href="#clearPasswordResetsModal" class="btn btn-xs btn-primary">
<i class="fa fa-fw fa-trash-o"></i> Clear expired
</a>
<a href="#deletePasswordResetsModal" class="btn btn-xs btn-danger">
<i class="fa fa-fw fa-trash-o"></i> Delete all
</a>
</div>
</div>
<div class="box-body no-padding">
<div class="table-responsive">
<table class="table table-condensed table-hover no-margin">
<thead>
<tr>
<th>Email</th>
<th>Full name</th>
<th>Created at</th>
<th class="text-center">Expired</th>
<th class="text-right" style="width: 80px;">Actions</th>
</tr>
</thead>
<tbody>
@if ($resets->count())
@foreach ($resets as $reset)
<tr>
<td>{{ $reset->email }}</td>
<td>
{{ $reset->user->full_name }}
</td>
<td><small>{{ $reset->created_at }}</small></td>
<td class="text-center">
@if ($reset->isExpired())
<span class="label label-warning">Yes</span>
@else
<span class="label label-success">No</span>
@endif
</td>
<td class="text-right">
<a href="{{ route('auth::foundation.users.show', [$reset->user->hashed_id]) }}" class="btn btn-xs btn-info" data-toggle="tooltip" data-original-title="Show">
<i class="fa fa-fw fa-search"></i>
</a>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="6" class="text-center">
<span class="label label-default">The password resets list is empty.</span>
</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
@if ($resets->hasPages())
<div class="box-footer clearfix">
{!! $resets->render() !!}
</div>
@endif
</div>
@endsection

@section('modals')
<div id="clearPasswordResetsModal" class="modal fade">
<div class="modal-dialog">
{{ Form::open(['route' => 'auth::foundation.password-resets.clear', 'method' => 'DELETE', 'class' => 'form form-loading', 'id' => 'clearPasswordResetsForm', 'autocomplete' => 'off']) }}
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Clear all expired password resets</h4>
</div>
<div class="modal-body">
<p>Are you sure to <span class="label label-primary">clear</span> all the expired password resets ?</p>
</div>
<div class="modal-footer">
{{ Form::button('Cancel', ['class' => 'btn btn-sm btn-default pull-left', 'data-dismiss' => 'modal']) }}
<button type="submit" class="btn btn-sm btn-primary" data-loading-text="Loading&hellip;">
<i class="fa fa-fw fa-trash-o"></i> Clear
</button>
</div>
</div>
{{ Form::close() }}
</div>
</div>

<div id="deletePasswordResetsModal" class="modal fade">
<div class="modal-dialog">
{{ Form::open(['route' => 'auth::foundation.password-resets.delete', 'method' => 'DELETE', 'class' => 'form form-loading', 'id' => 'deletePasswordResetsForm', 'autocomplete' => 'off']) }}
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Delete all password resets</h4>
</div>
<div class="modal-body">
<p>Are you sure to <span class="label label-danger">delete</span> all password resets ?</p>
</div>
<div class="modal-footer">
{{ Form::button('Cancel', ['class' => 'btn btn-sm btn-default pull-left', 'data-dismiss' => 'modal']) }}
<button type="submit" class="btn btn-sm btn-danger" data-loading-text="Loading&hellip;">
<i class="fa fa-fw fa-trash-o"></i> Delete
</button>
</div>
</div>
{{ Form::close() }}
</div>
</div>
@endsection

@section('scripts')
<script>
$(function () {
var $clearPasswordResetsModal = $('div#clearPasswordResetsModal'),
$clearPasswordResetsForm = $('form#clearPasswordResetsForm');
$('a[href="#clearPasswordResetsModal"]').on('click', function (e) {
e.preventDefault();
$clearPasswordResetsModal.modal('show');
});
$clearPasswordResetsForm.submit(function (e) {
e.preventDefault();
var $submitBtn = $clearPasswordResetsForm.find('button[type="submit"]');
$submitBtn.button('loading');
$.ajax({
url: $clearPasswordResetsForm.attr('action'),
type: $clearPasswordResetsForm.attr('method'),
dataType: 'json',
data: $clearPasswordResetsForm.serialize(),
success: function (data, textStatus, xhr) {
if (data.status === 'success') {
$clearPasswordResetsModal.modal('hide');
location.reload();
}
else {
alert('ERROR ! Check the console !');
console.error(data.message);
$submitBtn.button('reset');
}
},
error: function (xhr, textStatus, errorThrown) {
alert('AJAX ERROR ! Check the console !');
console.error(xhr);
$submitBtn.button('reset');
}
});
return false;
})
var $deletePasswordResetsModal = $('div#deletePasswordResetsModal'),
$deletePasswordResetsForm = $('form#deletePasswordResetsForm');
$('a[href="#deletePasswordResetsModal"]').on('click', function (e) {
e.preventDefault();
$deletePasswordResetsModal.modal('show');
});
$deletePasswordResetsForm.submit(function (e) {
e.preventDefault();
var $submitBtn = $deletePasswordResetsForm.find('button[type="submit"]');
$submitBtn.button('loading');
$.ajax({
url: $deletePasswordResetsForm.attr('action'),
type: $deletePasswordResetsForm.attr('method'),
dataType: 'json',
data: $deletePasswordResetsForm.serialize(),
success: function (data, textStatus, xhr) {
if (data.status === 'success') {
$deletePasswordResetsModal.modal('hide');
location.reload();
}
else {
alert('ERROR ! Check the console !');
console.error(data.message);
$submitBtn.button('reset');
}
},
error: function (xhr, textStatus, errorThrown) {
alert('AJAX ERROR ! Check the console !');
console.error(xhr);
$submitBtn.button('reset');
}
});
return false;
})
});
</script>
@endsection
2 changes: 1 addition & 1 deletion resources/views/foundation/permissions/list.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="box box-success">
<div class="box-header with-border">
<span class="label label-info" style="margin-right: 5px;">
Total of permissions : {{ $permissions->total() }}
Total : {{ $permissions->total() }}
</span>
@if ($permissions->hasPages())
<span class="label label-info">
Expand Down
2 changes: 1 addition & 1 deletion resources/views/foundation/roles/list.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="box box-warning">
<div class="box-header">
<span class="label label-info" style="margin-right: 5px;">
Total of roles : {{ $roles->total() }}
Total : {{ $roles->total() }}
</span>
@if ($roles->hasPages())
<span class="label label-info">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<div class="box">
<div class="box-header with-border">
<h2 class="box-title">Password reset</h2>
<div class="box-tools">
<a href="#deletePasswordResetModal" class="btn btn-xs btn-danger">
<i class="fa fa-fw fa-trash-o"></i> Delete
</a>
</div>
</div>
<div class="box-body no-padding">
<table class="table table-condensed no-margin">
<tr>
<td>
<b>Created at :</b>
</td>
<td class="text-right">
<small>{{ $user->passwordReset->created_at }}</small>
</td>
</tr>
<tr>
<td><b>Expired :</b></td>
<td class="text-right">
@if ($user->passwordReset->isExpired())
<span class="label label-warning">Yes</span>
@else
<span class="label label-success">No</span>
@endif
</td>
</tr>
</table>
</div>
</div>

@section('modals')
@parent
@endsection
41 changes: 41 additions & 0 deletions resources/views/foundation/users/_includes/roles-table.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<div class="box box-warning">
<div class="box-header with-border">
<h3 class="box-title">Roles</h3>
</div>
<div class="box-body no-padding">
<div class="table-responsive">
<table class="table table-condensed no-margin">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th class="text-right">Actions</th>
</tr>
</thead>
<tbody>
@if ($user->roles->count())
@foreach ($user->roles as $role)
<tr>
<td><span class="label label-primary">{{ $role->name }}</span></td>
<td>{{ $role->description }}</td>
<td class="text-right">
@can(Arcanesoft\Auth\Policies\RolesPolicy::PERMISSION_SHOW)
<a href="{{ route('auth::foundation.roles.show', [$role->hashed_id]) }}" class="btn btn-xs btn-info" data-toggle="tooltip" data-original-title="Show">
<i class="fa fa-fw fa-search"></i>
</a>
@endcan
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="3" class="text-center">
<span class="label label-default">This user has no roles.</span>
</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion resources/views/foundation/users/list.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="box box-primary">
<div class="box-header with-border">
<span class="label label-info" style="margin-right: 5px;">
Total of users : {{ $users->total() }}
Total : {{ $users->total() }}
</span>

@if ($users->hasPages())
Expand Down
Loading

0 comments on commit 34cc619

Please sign in to comment.