#9, #12: Change password is now working. Updated the default album view to Bootstrap v4's cards.

This commit is contained in:
Andy Heathershaw 2017-04-11 18:31:56 +01:00
parent e1b80ae096
commit ac2a24187d
10 changed files with 81 additions and 49 deletions

3
.idea/deployment.xml generated
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" autoUpload="On explicit save action" serverName="Development">
<component name="PublishConfigData" serverName="Development">
<serverData>
<paths name="Development">
<serverdata>
@ -10,6 +10,5 @@
</serverdata>
</paths>
</serverData>
<option name="myAutoUpload" value="ON_EXPLICIT_SAVE" />
</component>
</project>

View File

@ -6,6 +6,8 @@ use App\Facade\Theme;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Password;
class ChangePasswordController extends Controller
{
@ -28,8 +30,46 @@ class ChangePasswordController extends Controller
$this->middleware('auth');
}
public function processChangePassword(Request $request)
{
$this->validate($request, ['password' => 'required|confirmed|min:6']);
// Here we will attempt to reset the user's password. If it is successful we
// will update the password on an actual user model and persist it to the
// database. Otherwise we will parse the error and return the response.
$response = $this->broker()->reset(
$this->credentials($request), function ($user, $password) {
$this->resetPassword($user, $password);
}
);
// If the password was successfully reset, we will redirect the user back to
// the application's home authenticated view. If there is an error we can
// redirect them back to where they came from with their error message.
return $response == Password::PASSWORD_RESET
? $this->sendResetResponse($response)
: $this->sendResetFailedResponse($request, $response);
}
public function showChangePasswordForm(Request $request)
{
return Theme::render('auth.passwords.change_password');
}
protected function credentials(Request $request)
{
$data = $request->only('password', 'password_confirmation', 'token');
$data['email'] = Auth::user()->email;
// Create a token for the password broker to validate
$data['token'] = $this->broker()->createToken($this->getUser());
return $data;
}
protected function sendResetResponse($response)
{
return redirect($this->redirectPath())
->with('status', trans('passwords.changed'));
}
}

View File

@ -13,6 +13,7 @@ return [
|
*/
'changed' => 'Your password has been changed.',
'password' => 'Passwords must be at least six characters and match the confirmation.',
'reset' => 'Your password has been reset!',
'sent' => 'We have sent your password reset link to your e-mail address.',

View File

@ -45,7 +45,7 @@
{{ csrf_field() }}
@if (count($existing_groups) > 0)
<div class="panel-group" id="groups-accordion" role="tablist" aria-multiselectable="true">
<div id="groups-accordion" role="tablist" aria-multiselectable="true">
@foreach ($existing_groups as $group)
@include(Theme::viewName('partials.album_permissions'), [
'key_id' => 'group_' . $group->id,
@ -59,7 +59,7 @@
</div>
@endif
<div class="row">
<div class="row mt-3">
<div class="col-md-4">
<select class="form-control" name="group_id" style="margin-bottom: 2px;"@if (count($add_new_groups) == 0) disabled="disabled"@endif>
@foreach ($add_new_groups as $group)
@ -84,7 +84,7 @@
<form action="{{ route('albums.set_user_permissions', ['id' => $album->id]) }}" method="post">
{{ csrf_field() }}
<div class="panel-group" id="users-accordion" role="tablist" aria-multiselectable="true">
<div id="users-accordion" role="tablist" aria-multiselectable="true">
{{-- Anonymous users --}}
@include(Theme::viewName('partials.album_permissions'), [
'key_id' => 'anonymous',
@ -107,7 +107,7 @@
@endforeach
</div>
<div class="row">
<div class="row mt-3">
<div class="col-md-4">
<input class="form-control" name="user_name" id="user-search-textbox" size="20" style="margin-bottom: 2px;" />
<input type="hidden" name="user_id" id="user-id-field" />
@ -248,16 +248,6 @@
$('.nav-tabs a[href="#upload-tab"]').tab('show');
});
{{-- Photo editing tasks - the buttons beneath the photos in partials/single_photo_admin --}}
/*$('a.change-album').click(editViewModel.changeAlbum);
$('a.delete-photo').click(editViewModel.delete);
$('a.flip-photo-both').click(editViewModel.flipBoth);
$('a.flip-photo-horizontal').click(editViewModel.flipHorizontal);
$('a.flip-photo-vertical').click(editViewModel.flipVertical);
$('a.regenerate-thumbnails').click(editViewModel.regenerateThumbnails);
$('a.rotate-photo-left').click(editViewModel.rotateLeft);
$('a.rotate-photo-right').click(editViewModel.rotateRight);*/
{{-- Photo uploads using AJAX --}}
if (window.FormData)
{

View File

@ -14,9 +14,13 @@
</ul>
</div>
<div class="card-block">
<form role="form" method="POST" action="{{ url('/password/change') }}">
<form role="form" method="POST" action="{{ route('auth.processChangePassword') }}">
{{ csrf_field() }}
@if ($errors->has('email'))
<div class="alert alert-danger">{{ $errors->first('email') }}</div>
@endif
<div class="form-group row{{ $errors->has('password') ? ' has-danger' : '' }}">
<label for="password" class="col-md-4 col-form-label text-md-right">@lang('forms.password_label')</label>

View File

@ -1,21 +1,21 @@
@extends('themes.base.layout')
@section('title', $album->name)
@section('breadcrumb')
<div class="breadcrumb">
<div class="container">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">Gallery</a></li>
<li class="active">{{ $album->name }}</li>
</ol>
@section('content')
<div class="container-fluid">
<div class="row">
<div class="col">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
<li class="breadcrumb-item active">{{ $album->name }}</li>
</ol>
</div>
</div>
</div>
@endsection
@section('content')
<div class="container album-container">
<div class="container-fluid album-container">
<div class="row">
<div class="col-xs-12">
<div class="col">
<div class="pull-right">
@include(\App\Facade\Theme::viewName('partials.album_view_selector'))
</div>
@ -28,19 +28,22 @@
<div class="row">
@foreach ($photos as $photo)
<div class="col-xs-12 col-sm-4 photo">
<div class="panel panel-default">
<div class="panel-body" style="padding: 4px;">
<a href="{{ $photo->url() }}"><img src="{{ $photo->thumbnailUrl('preview') }}" alt="" class="img-responsive img-rounded"/></a>
<div class="col-sm-6 col-md-4 col-lg-3 photo">
<div class="card">
<img src="{{ $photo->thumbnailUrl('preview') }}" alt="" class="card-img-top"/>
<div class="card-block">
<h4 class="card-title"><a href="{{ $photo->url() }}">{{ $photo->name }}</a></h4>
</div>
<div class="card-footer">
<small class="text-muted"><i class="fa fa-fw fa-calendar"></i> {{ date('Y-m-d H:i', $photo->taken_at) }}</small>
</div>
<div class="panel-footer"><b><a href="{{ $photo->url() }}">{{ $photo->name }}</a></b></div>
</div>
</div>
@endforeach
</div>
<div class="row" style="margin-top: 15px;">
<div class="col-xs-12 text-center">
<div class="col text-center">
{{ $photos->links() }}
</div>
</div>

View File

@ -2,20 +2,14 @@
@section('title', $album->name)
@section('breadcrumb')
<div class="breadcrumb">
<div class="container">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
<li class="active">{{ $album->name }}</li>
</ol>
</div>
</div>
<li class="breadcrumb-item"><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
<li class="breadcrumb-item active">{{ $album->name }}</li>
@endsection
@section('content')
<div class="container album-container">
<div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2 text-center">
<div class="col-md-8 offset-md-2 text-center">
<h1>@lang('gallery.album_no_results_heading')</h1>
<p style="line-height: 1.6em;">@lang('gallery.album_no_results_text', ['admin_link' => sprintf('<a href="%s">%s</a>', route('admin'), trans('admin.title'))])</p>
<p style="margin-bottom: 30px; line-height: 1.6em;">@lang('gallery.album_no_results_text_2')</p>

View File

@ -6,7 +6,7 @@
@if (count($albums) > 0)
<div class="row album-photo-cards">
@foreach ($albums as $album)
<div class="col-md-3">
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="card">
<img class="card-img-top" src="{{ $album->thumbnailUrl('preview') }}"/>
<div class="card-block">

View File

@ -1,11 +1,11 @@
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading-{{ $key_id }}">
<h4 class="panel-title">
<div class="card">
<div class="card-header" role="tab" id="heading-{{ $key_id }}">
<h5 class="mb-0">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#{{ $parent_id }}" href="#collapse-{{ $key_id }}" aria-expanded="true" aria-controls="collapse-{{ $key_id }}">{{ $title }}</a>
</h4>
</h5>
</div>
<div id="collapse-{{ $key_id }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-{{ $key_id }}">
<div class="panel-body">
<div class="card-block">
<p style="margin-bottom: 20px;"><a class="select-all" href="#">Select All</a> &middot; <a class="select-none" href="">Select None</a></p>
@foreach ($all_permissions as $permission)

View File

@ -65,6 +65,7 @@ Route::group(['prefix' => 'install'], function () {
Route::get('/', 'Gallery\DefaultController@index')->name('home');
Route::get('/activate/{token}', 'Auth\ActivateController@activate')->name('auth.activate');
Route::get('/password/change', 'Auth\ChangePasswordController@showChangePasswordForm')->name('auth.changePassword');
Route::post('/password/change', 'Auth\ChangePasswordController@processChangePassword')->name('auth.processChangePassword');
Route::get('{albumUrlAlias}', 'Gallery\AlbumController@index')->name('viewAlbum');
Route::get('{albumUrlAlias}/{photoFilename}', 'Gallery\PhotoController@show')->name('viewPhoto');
Route::get('photo/{albumUrlAlias}/{photoFilename}', 'Gallery\PhotoController@download')->name('downloadPhoto');