#4: Known users pre-fill the user/email password, added user Gravatar for the comment form, and a link to logout. Login/logout redirects back to the previous page.

This commit is contained in:
Andy Heathershaw 2018-09-19 13:49:53 +01:00
parent 1802aa84d8
commit 3f7badd98a
5 changed files with 37 additions and 8 deletions

View File

@ -6,6 +6,7 @@ use App\Facade\Theme;
use App\Facade\UserConfig; use App\Facade\UserConfig;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\User; use App\User;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Laravel\Socialite\One\TwitterProvider; use Laravel\Socialite\One\TwitterProvider;
@ -29,6 +30,8 @@ class LoginController extends Controller
use AuthenticatesUsers; use AuthenticatesUsers;
protected $generator;
/** /**
* Where to redirect users after login / registration. * Where to redirect users after login / registration.
* *
@ -41,9 +44,19 @@ class LoginController extends Controller
* *
* @return void * @return void
*/ */
public function __construct() public function __construct(UrlGenerator $generator)
{ {
$this->middleware('guest', ['except' => 'logout']); $this->middleware('guest', ['except' => 'logout']);
$this->generator = $generator;
}
public function logout(Request $request)
{
$this->guard()->logout();
$request->session()->invalidate();
return redirect()->back();
} }
protected function attemptLogin(Request $request) protected function attemptLogin(Request $request)
@ -88,6 +101,8 @@ class LoginController extends Controller
*/ */
public function showLoginForm(Request $request) public function showLoginForm(Request $request)
{ {
$request->getSession()->put('url.intended', $this->generator->previous(false));
return Theme::render('auth.v2_unified', [ return Theme::render('auth.v2_unified', [
'active_tab' => 'login', 'active_tab' => 'login',
'info' => $request->session()->get('info'), 'info' => $request->session()->get('info'),

View File

@ -62,6 +62,10 @@
width: auto; width: auto;
} }
.photo-comment .card-subtitle {
font-size: smaller;
}
.stats-table .icon-col { .stats-table .icon-col {
font-size: 1.4em; font-size: 1.4em;
width: 20%; width: 20%;

View File

@ -29,6 +29,7 @@ return [
'manage_album_link' => 'Manage', 'manage_album_link' => 'Manage',
'manage_album_link_2' => 'Manage Album', 'manage_album_link_2' => 'Manage Album',
'next_button' => 'Next Photo »', 'next_button' => 'Next Photo »',
'not_you_logout' => 'Not you? Logout',
'open_album_link' => 'Open Album', 'open_album_link' => 'Open Album',
'other_albums_description' => 'You may also be interested in the following albums.', 'other_albums_description' => 'You may also be interested in the following albums.',
'other_albums_description_empty' => 'The <b>:album_name</b> album does not contain any photos - however you may also be interested in the following albums.', 'other_albums_description_empty' => 'The <b>:album_name</b> album does not contain any photos - however you may also be interested in the following albums.',

View File

@ -1,5 +1,6 @@
@php @php
$is_reply = isset($reply_comment); $is_reply = isset($reply_comment);
$is_known_user = !is_null(Auth::user())
@endphp @endphp
{{-- Show a previous of the comment we're replying to --}} {{-- Show a previous of the comment we're replying to --}}
@ -18,7 +19,7 @@ $is_reply = isset($reply_comment);
<div class="form-group"> <div class="form-group">
<label for="commentor-name">@lang('forms.name_label')</label> <label for="commentor-name">@lang('forms.name_label')</label>
<input type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" id="commentor-name" name="name" value="{{ old('name') }}"/> <input type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" id="commentor-name" name="name" value="{{ old('name', ($is_known_user ? Auth::user()->name : '')) }}"{{ $is_known_user ? ' readonly="readonly"' : '' }}/>
@if ($errors->has('name')) @if ($errors->has('name'))
<div class="invalid-feedback"> <div class="invalid-feedback">
@ -29,13 +30,17 @@ $is_reply = isset($reply_comment);
<div class="form-group"> <div class="form-group">
<label for="commentor-email">@lang('forms.email_label')</label> <label for="commentor-email">@lang('forms.email_label')</label>
<input type="text" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" id="commentor-email" name="email" value="{{ old('email') }}" placeholder="@lang('forms.email_placeholder')"/> <input type="text" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" id="commentor-email" name="email" value="{{ old('email', ($is_known_user ? Auth::user()->email : '')) }}" placeholder="@lang('forms.email_placeholder')"{{ $is_known_user ? ' readonly="readonly"' : '' }}//>
@if ($errors->has('email')) @if ($errors->has('email'))
<div class="invalid-feedback"> <div class="invalid-feedback">
<strong>{{ $errors->first('email') }}</strong> <strong>{{ $errors->first('email') }}</strong>
</div> </div>
@endif @endif
@if ($is_known_user)
<a class="btn btn-link" href="{{ url('/logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">@lang('gallery.not_you_logout')</a>
@endif
</div> </div>
<div class="form-group"> <div class="form-group">
@ -64,7 +69,10 @@ $is_reply = isset($reply_comment);
function initTinyMce(selector) function initTinyMce(selector)
{ {
tinymce.init({ tinymce.init({
selector: selector selector: selector,
plugins: 'textcolor lists link image',
toolbar1: 'bold italic strikethrough forecolor backcolor | link image | alignleft aligncenter alignright alignjustify | numlist bullist | removeformat',
menubar: false
}); });
} }

View File

@ -4,11 +4,12 @@
<div class="card photo-comment mt-2" data-comment-id="{{ $comment->id }}"@if (!$is_reply) style="margin-left: {{ $comment->depth() * 20 }}px;"@endif> <div class="card photo-comment mt-2" data-comment-id="{{ $comment->id }}"@if (!$is_reply) style="margin-left: {{ $comment->depth() * 20 }}px;"@endif>
<div class="card-body"> <div class="card-body">
<h5 class="card-title"><b>{{ $comment->authorDisplayName() }}</b>:</h5> <img class="img-thumbnail rounded float-left mr-3 mb-2" src="{{ Theme::gravatarUrl($comment->email) }}" alt="{{ $comment->authorDisplayName() }}" title="{{ $comment->authorDisplayName() }}">
<h6 class="card-subtitle mb-2 text-muted">{{ date(UserConfig::get('date_format'), strtotime($comment->created_at)) }}</h6> <h5 class="card-title mt-1"><b>{{ $comment->authorDisplayName() }}</b></h5>
<p>{!! $comment->textAsHtml() !!}</p> <h6 class="card-subtitle mb-4 text-muted">{{ date(UserConfig::get('date_format'), strtotime($comment->created_at)) }}</h6>
{!! $comment->textAsHtml() !!}
@if (!$is_reply && $comment->depth() < UserConfig::get('photo_comments_thread_depth')) @if (!$is_reply && ($comment->depth() < UserConfig::get('photo_comments_thread_depth') - 1))
<a href="{{ $photo->replyToCommentFormUrl($comment->id) }}" v-on:click="replyToComment" class="card-link">@lang('gallery.photo_comments_reply_action')</a> <a href="{{ $photo->replyToCommentFormUrl($comment->id) }}" v-on:click="replyToComment" class="card-link">@lang('gallery.photo_comments_reply_action')</a>
@endif @endif
</div> </div>