From 6d970a4cc396996503fbc952a23666928f0412ee Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 8 Apr 2018 15:46:32 -0500 Subject: [PATCH] Finalize login page! --- app/Http/Controllers/Auth/LoginController.php | 13 +++++++++++++ app/Providers/AppServiceProvider.php | 2 ++ resources/assets/pterodactyl/scripts/app.js | 7 ++++--- .../scripts/components/auth/ForgotPassword.vue | 4 +++- .../scripts/components/auth/ResetPassword.vue | 4 +++- .../scripts/components/auth/TwoFactorForm.vue | 3 ++- resources/lang/en/strings.php | 3 +++ resources/themes/pterodactyl/auth/login.blade.php | 5 ----- .../pterodactyl/templates/auth/core.blade.php | 4 ++-- routes/auth.php | 11 ++++++++--- 10 files changed, 40 insertions(+), 16 deletions(-) delete mode 100644 resources/themes/pterodactyl/auth/login.blade.php diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 522a994f6..5a3a3ffb6 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -4,10 +4,23 @@ namespace Pterodactyl\Http\Controllers\Auth; use Illuminate\Http\Request; use Illuminate\Http\JsonResponse; +use Illuminate\Contracts\View\View; use Pterodactyl\Exceptions\Repository\RecordNotFoundException; class LoginController extends AbstractLoginController { + /** + * Handle all incoming requests for the authentication routes and render the + * base authentication view component. Vuejs will take over at this point and + * turn the login area into a SPA. + * + * @return \Illuminate\Contracts\View\View + */ + public function index(): View + { + return view('templates/auth.core'); + } + /** * Handle a login request to the application. * diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 1adede6c6..04c6b75d6 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -7,6 +7,7 @@ use Cache; use Pterodactyl\Models\User; use Pterodactyl\Models\Server; use Pterodactyl\Models\Subuser; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Schema; use Igaster\LaravelTheme\Facades\Theme; use Illuminate\Support\ServiceProvider; @@ -21,6 +22,7 @@ class AppServiceProvider extends ServiceProvider */ public function boot() { + Blade::doubleEncode(); Schema::defaultStringLength(191); User::observe(UserObserver::class); diff --git a/resources/assets/pterodactyl/scripts/app.js b/resources/assets/pterodactyl/scripts/app.js index b2e62753e..5586874a6 100644 --- a/resources/assets/pterodactyl/scripts/app.js +++ b/resources/assets/pterodactyl/scripts/app.js @@ -43,15 +43,16 @@ Vue.i18n.add('en', Locales.en); Vue.i18n.set('en'); const router = new VueRouter({ + mode: 'history', routes: [ { name: 'login', - path: '/', + path: '/auth/login', component: Login, }, { name: 'forgot-password', - path: '/forgot-password', + path: '/auth/password', component: Login, }, { @@ -61,7 +62,7 @@ const router = new VueRouter({ }, { name: 'reset-password', - path: '/reset-password/:token', + path: '/auth/password/reset/:token', component: ResetPassword, props: function (route) { return { diff --git a/resources/assets/pterodactyl/scripts/components/auth/ForgotPassword.vue b/resources/assets/pterodactyl/scripts/components/auth/ForgotPassword.vue index 22d00c843..97029e1ce 100644 --- a/resources/assets/pterodactyl/scripts/components/auth/ForgotPassword.vue +++ b/resources/assets/pterodactyl/scripts/components/auth/ForgotPassword.vue @@ -31,7 +31,9 @@
- + {{ $t('auth.go_to_login') }}
diff --git a/resources/assets/pterodactyl/scripts/components/auth/ResetPassword.vue b/resources/assets/pterodactyl/scripts/components/auth/ResetPassword.vue index 625926296..6e9940e17 100644 --- a/resources/assets/pterodactyl/scripts/components/auth/ResetPassword.vue +++ b/resources/assets/pterodactyl/scripts/components/auth/ResetPassword.vue @@ -50,7 +50,9 @@
- + {{ $t('auth.go_to_login') }}
diff --git a/resources/assets/pterodactyl/scripts/components/auth/TwoFactorForm.vue b/resources/assets/pterodactyl/scripts/components/auth/TwoFactorForm.vue index 36ec86907..c207dd529 100644 --- a/resources/assets/pterodactyl/scripts/components/auth/TwoFactorForm.vue +++ b/resources/assets/pterodactyl/scripts/components/auth/TwoFactorForm.vue @@ -18,7 +18,8 @@
+ :to="{ name: 'login' }" + > Back to Login
diff --git a/resources/lang/en/strings.php b/resources/lang/en/strings.php index 5b9173866..4f1d611ef 100644 --- a/resources/lang/en/strings.php +++ b/resources/lang/en/strings.php @@ -84,4 +84,7 @@ return [ 'sat' => 'Saturday', ], 'last_used' => 'Last Used', + + // Copyright Line + 'copyright' => '© 2015 - :year Pterodactyl Software', ]; diff --git a/resources/themes/pterodactyl/auth/login.blade.php b/resources/themes/pterodactyl/auth/login.blade.php deleted file mode 100644 index 04730edf7..000000000 --- a/resources/themes/pterodactyl/auth/login.blade.php +++ /dev/null @@ -1,5 +0,0 @@ -@extends('templates/auth.core') - -@section('title') - Login -@endsection diff --git a/resources/themes/pterodactyl/templates/auth/core.blade.php b/resources/themes/pterodactyl/templates/auth/core.blade.php index a76d4e599..d84751df0 100644 --- a/resources/themes/pterodactyl/templates/auth/core.blade.php +++ b/resources/themes/pterodactyl/templates/auth/core.blade.php @@ -1,6 +1,6 @@ - {{ config('app.name', 'Pterodactyl') }} - @yield('title') + {{ config('app.name', 'Pterodactyl') }} @section('meta') @@ -23,7 +23,7 @@

- © 2015 - {{ date('Y') }} Pterodactyl Software + {{ trans('strings.copyright', ['year' => date('Y')]) }}

diff --git a/routes/auth.php b/routes/auth.php index 261c1bb64..0511c96e2 100644 --- a/routes/auth.php +++ b/routes/auth.php @@ -9,14 +9,19 @@ | */ Route::group(['middleware' => 'guest'], function () { - // Login specific routes - Route::get('/login', 'LoginController@showLoginForm')->name('auth.login'); + // These routes are defined so that we can continue to reference them programatically. + // They all route to the same controller function which passes off to Vuejs. + Route::get('/login', 'LoginController@index')->name('auth.login'); + Route::get('/password', 'LoginController@index')->name('auth.forgot-password'); + Route::get('/password/reset/{token}', 'LoginController@index')->name('auth.reset'); + + // Login endpoints. Route::post('/login', 'LoginController@login')->middleware('recaptcha'); Route::post('/login/checkpoint', 'LoginCheckpointController')->name('auth.login-checkpoint'); // Forgot password route. A post to this endpoint will trigger an // email to be sent containing a reset token. - Route::post('/password', 'ForgotPasswordController@sendResetLinkEmail')->name('auth.forgot-password')->middleware('recaptcha'); + Route::post('/password', 'ForgotPasswordController@sendResetLinkEmail')->middleware('recaptcha'); // Password reset routes. This endpoint is hit after going through // the forgot password routes to acquire a token (or after an account