From 3f7badd98a4577aa0970ee1114951e8f92179f06 Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Wed, 19 Sep 2018 13:49:53 +0100 Subject: [PATCH] #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. --- app/Http/Controllers/Auth/LoginController.php | 17 ++++++++++++++++- resources/assets/css/gallery.css | 4 ++++ resources/lang/en/gallery.php | 1 + .../photo_comments_reply_form.blade.php | 14 +++++++++++--- .../partials/photo_single_comment.blade.php | 9 +++++---- 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 53009e4..257bee4 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -6,6 +6,7 @@ use App\Facade\Theme; use App\Facade\UserConfig; use App\Http\Controllers\Controller; use App\User; +use Illuminate\Contracts\Routing\UrlGenerator; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; use Laravel\Socialite\One\TwitterProvider; @@ -29,6 +30,8 @@ class LoginController extends Controller use AuthenticatesUsers; + protected $generator; + /** * Where to redirect users after login / registration. * @@ -41,9 +44,19 @@ class LoginController extends Controller * * @return void */ - public function __construct() + public function __construct(UrlGenerator $generator) { $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) @@ -88,6 +101,8 @@ class LoginController extends Controller */ public function showLoginForm(Request $request) { + $request->getSession()->put('url.intended', $this->generator->previous(false)); + return Theme::render('auth.v2_unified', [ 'active_tab' => 'login', 'info' => $request->session()->get('info'), diff --git a/resources/assets/css/gallery.css b/resources/assets/css/gallery.css index b045bb9..d9e5ce5 100644 --- a/resources/assets/css/gallery.css +++ b/resources/assets/css/gallery.css @@ -62,6 +62,10 @@ width: auto; } +.photo-comment .card-subtitle { + font-size: smaller; +} + .stats-table .icon-col { font-size: 1.4em; width: 20%; diff --git a/resources/lang/en/gallery.php b/resources/lang/en/gallery.php index 84dca7e..59705c6 100644 --- a/resources/lang/en/gallery.php +++ b/resources/lang/en/gallery.php @@ -29,6 +29,7 @@ return [ 'manage_album_link' => 'Manage', 'manage_album_link_2' => 'Manage Album', 'next_button' => 'Next Photo »', + 'not_you_logout' => 'Not you? Logout', 'open_album_link' => 'Open Album', 'other_albums_description' => 'You may also be interested in the following albums.', 'other_albums_description_empty' => 'The :album_name album does not contain any photos - however you may also be interested in the following albums.', diff --git a/resources/views/themes/base/partials/photo_comments_reply_form.blade.php b/resources/views/themes/base/partials/photo_comments_reply_form.blade.php index 780bdaa..3288811 100644 --- a/resources/views/themes/base/partials/photo_comments_reply_form.blade.php +++ b/resources/views/themes/base/partials/photo_comments_reply_form.blade.php @@ -1,5 +1,6 @@ @php $is_reply = isset($reply_comment); +$is_known_user = !is_null(Auth::user()) @endphp {{-- Show a previous of the comment we're replying to --}} @@ -18,7 +19,7 @@ $is_reply = isset($reply_comment);
- + @if ($errors->has('name'))
@@ -29,13 +30,17 @@ $is_reply = isset($reply_comment);
- + @if ($errors->has('email'))
{{ $errors->first('email') }}
@endif + + @if ($is_known_user) + @lang('gallery.not_you_logout') + @endif
@@ -64,7 +69,10 @@ $is_reply = isset($reply_comment); function initTinyMce(selector) { 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 }); } diff --git a/resources/views/themes/base/partials/photo_single_comment.blade.php b/resources/views/themes/base/partials/photo_single_comment.blade.php index ea05a70..7ea2a24 100644 --- a/resources/views/themes/base/partials/photo_single_comment.blade.php +++ b/resources/views/themes/base/partials/photo_single_comment.blade.php @@ -4,11 +4,12 @@
-
{{ $comment->authorDisplayName() }}:
-
{{ date(UserConfig::get('date_format'), strtotime($comment->created_at)) }}
-

{!! $comment->textAsHtml() !!}

+ {{ $comment->authorDisplayName() }} +
{{ $comment->authorDisplayName() }}
+
{{ date(UserConfig::get('date_format'), strtotime($comment->created_at)) }}
+ {!! $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)) @lang('gallery.photo_comments_reply_action') @endif