Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3748334
D449.id1087.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D449.id1087.diff
View Options
diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php
--- a/app/Http/Controllers/Auth/AuthController.php
+++ b/app/Http/Controllers/Auth/AuthController.php
@@ -10,6 +10,7 @@
use AuthGrove\Services\Registrar;
use AuthGrove\Models\User;
+use Config;
use Route;
class AuthController extends Controller implements RegistrarContract
@@ -51,28 +52,47 @@
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}
+ ///
+ /// Routes
+ ///
+
+ /**
+ * Gets the URL prefix for the authentication routes.
+ *
+ * @return string
+ */
+ protected static function getRoutePrefix () {
+ return Config::get('auth.route');
+ }
+
+ public static function getRoute ($action) {
+ return static::getRoutePrefix() . '/' . $action;
+ }
+
/**
* Registers auth routes.
*/
public static function registerRoutes () {
+ $auth = static::getRoutePrefix();
+
// Login
- Route::get('/auth', ['as' => 'auth.login', 'uses' => 'Auth\AuthController@showLoginForm']);
- Route::get('/auth/login', ['as' => 'auth.login', 'uses' => 'Auth\AuthController@showLoginForm']);
- Route::post('/auth/login', ['as' => 'auth.login', 'uses' => 'Auth\AuthController@login']);
+ Route::get($auth, ['as' => 'auth.login', 'uses' => 'Auth\AuthController@showLoginForm']);
+ Route::get($auth . '/login', ['as' => 'auth.login', 'uses' => 'Auth\AuthController@showLoginForm']);
+ Route::post($auth . '/login', ['as' => 'auth.login', 'uses' => 'Auth\AuthController@login']);
// Logout
- Route::get('/auth/logout', ['as' => 'auth.logout', 'uses' => 'Auth\AuthController@logout']);
+ Route::get($auth . '/logout', ['as' => 'auth.logout', 'uses' => 'Auth\AuthController@logout']);
// Registration
- Route::get('/auth/register', ['as' => 'auth.register', 'uses' => 'Auth\AuthController@showRegistrationForm']);
- Route::post('/auth/register', ['as' => 'auth.register', 'uses' => 'Auth\AuthController@register']);
+ Route::get($auth . '/register', ['as' => 'auth.register', 'uses' => 'Auth\AuthController@showRegistrationForm']);
+ Route::post($auth . '/register', ['as' => 'auth.register', 'uses' => 'Auth\AuthController@register']);
// Recover account
- Route::get('/auth/recover', ['as' => 'auth.password.reset', 'uses' => 'Auth\PasswordController@getRecover']);
- Route::post('/auth/recover', ['as' => 'auth.password.reset', 'uses' => 'Auth\PasswordController@postRecover']);
+ Route::get($auth . '/recover', ['as' => 'auth.password.reset', 'uses' => 'Auth\PasswordController@getRecover']);
+ Route::post($auth . '/recover', ['as' => 'auth.password.reset', 'uses' => 'Auth\PasswordController@postRecover']);
// Reset password (with a token received by mail)
- Route::get('/auth/reset/{token?}', ['as' => 'auth.password.reset', 'uses' => 'Auth\PasswordController@getReset']);
- Route::post('/auth/reset', ['as' => 'auth.password.reset', 'uses' => 'Auth\PasswordController@reset']);
+ Route::get($auth . '/reset/{token?}', ['as' => 'auth.password.reset', 'uses' => 'Auth\PasswordController@getReset']);
+ Route::post($auth . '/reset', ['as' => 'auth.password.reset', 'uses' => 'Auth\PasswordController@reset']);
}
}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -2,6 +2,10 @@
use Illuminate\Support\ServiceProvider;
+use AuthGrove\Http\Controllers\Auth\AuthController;
+
+use Blade;
+
class AppServiceProvider extends ServiceProvider {
/**
@@ -9,9 +13,13 @@
*
* @return void
*/
- public function boot()
- {
- //
+ public function boot() {
+ // Blade templates can invoke AuthController::getRoute as authurl()
+ Blade::directive('authurl', function ($expression) {
+ preg_match("@\('(.*)'\)@", $expression, $matches); // ('foo') → foo
+ $action = $matches[1];
+ return url(AuthController::getRoute($action));
+ });
}
/**
diff --git a/config/auth.php b/config/auth.php
--- a/config/auth.php
+++ b/config/auth.php
@@ -104,4 +104,15 @@
],
],
+ /*
+ |--------------------------------------------------------------------------
+ | Routes
+ |--------------------------------------------------------------------------
+ |
+ | Routes handled by AuthController and PasswordController should start by:
+ |
+ */
+
+ 'route' => '/auth',
+
];
diff --git a/resources/views/app.blade.php b/resources/views/app.blade.php
--- a/resources/views/app.blade.php
+++ b/resources/views/app.blade.php
@@ -41,7 +41,7 @@
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ Auth::user()->getName() }} <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
- <li><a href="{{ url('/auth/logout') }}">@lang('panel.logout')</a></li>
+ <li><a href="@authurl('logout')">@lang('panel.logout')</a></li>
</ul>
</li>
</ul>
diff --git a/resources/views/auth/fatal-error.blade.php b/resources/views/auth/fatal-error.blade.php
new file mode 100644
--- /dev/null
+++ b/resources/views/auth/fatal-error.blade.php
@@ -0,0 +1,12 @@
+@extends('auth.master')
+
+@section('card-content')
+ <h1 class="title">@lang('app.title')</h1>
+ <p>@lang('auth.fatal-error')</p>
+ <p class="errors">
+@foreach ($errors->all() as $error)
+ {{ $error }}<br />
+@endforeach
+ </p>
+ <a href="@authurl('login')" class="action-link">@lang('login.goto-login')</a>
+@endsection
diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php
--- a/resources/views/auth/login.blade.php
+++ b/resources/views/auth/login.blade.php
@@ -3,7 +3,7 @@
@section('card-content')
<h1 class="title">@lang('app.title')</h1>
<img id="profile-img" class="profile-img-card" src="/images/profile-img-blank.png" alt="@lang('login.blankAvatarAlt')" />
- <form class="form-signin" role="form" method="POST" action="{{ url('/auth/login') }}">
+ <form class="form-signin" role="form" method="POST" action="@authurl('login')">
<div id="identity">
<span id="reauth-username" class="reauth-username"></span>
<input type="text" name="username" id="inputUsername" class="form-control"
@@ -15,7 +15,7 @@
@foreach ($errors->all() as $error)
{{ $error }}<br />
@endforeach
- <a href="{{ url('/auth/recover') }}" class="action-link">@lang('login.passwordRecovery')</a>
+ <a href="@authurl('recover')" class="action-link">@lang('login.passwordRecovery')</a>
</p>
@endif
@@ -27,7 +27,7 @@
</form>
<!-- /form -->
@if (count($errors) == 0)
- <a href="{{ url('/auth/recover') }}" class="action-link">@lang('login.passwordRecovery')</a><br />
+ <a href="@authurl('recover')" class="action-link">@lang('login.passwordRecovery')</a><br />
@endif
- <a href="{{ url('/auth/register') }}" class="action-link">@lang('login.registerAccount')</a>
+ <a href="@authurl('register')" class="action-link">@lang('login.registerAccount')</a>
@endsection
diff --git a/resources/views/auth/recover.blade.php b/resources/views/auth/recover.blade.php
--- a/resources/views/auth/recover.blade.php
+++ b/resources/views/auth/recover.blade.php
@@ -7,7 +7,7 @@
<p class="center"><img src="{{ url('/images/white-check.svg') }}" alt="Check mark" width="100px" /></p>
<p class="nav"><a href="{{ url('/') }}">@lang('pagination.previous') Back to login screen</a></p>
@else
- <form class="form-signin form-recover" role="form" method="POST" action="{{ url('/auth/recover') }}">
+ <form class="form-signin form-recover" role="form" method="POST" action="@authurl('recover')">
<div id="identity">
<input type="email" name="email" id="inputEmail" class="form-control"
value="{{ old('email') }}" placeholder="@lang('login.email')" required autofocus />
diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php
--- a/resources/views/auth/register.blade.php
+++ b/resources/views/auth/register.blade.php
@@ -2,7 +2,7 @@
@section('card-content')
<h1 class="title">@lang('login.registerAccount')</h1>
- <form class="form-signin form-register" role="form" method="POST" action="{{ url('/auth/register') }}">
+ <form class="form-signin form-register" role="form" method="POST" action="@authurl('register')">
<div id="identity">
<span id="reauth-username" class="reauth-username"></span>
<label for="inputUsername">@lang('login.username')</label>
diff --git a/resources/views/auth/reset.blade.php b/resources/views/auth/reset.blade.php
--- a/resources/views/auth/reset.blade.php
+++ b/resources/views/auth/reset.blade.php
@@ -3,7 +3,7 @@
@section('card-content')
<div class="container-fluid">
<h1 class="title">@lang('login.resetPassword')</h1>
- <form class="form-signin form-reset" role="form" method="POST" action="{{ url('/auth/reset') }}">
+ <form class="form-signin form-reset" role="form" method="POST" action="@authurl('reset')">
<div id="identity">
<label for="inputEmail">@lang('login.email')</label>
<input type="email" name="email" id="inputEmail" class="form-control"
diff --git a/resources/views/emails/password.blade.php b/resources/views/emails/password.blade.php
--- a/resources/views/emails/password.blade.php
+++ b/resources/views/emails/password.blade.php
@@ -10,7 +10,7 @@
@lang('emails.reset-password-callforaction')
-{{ url('auth/reset/' . $token) }}
+@authurl('reset/{{ $token }}')
@lang('emails.reset-password-origin')
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 08:18 (21 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2248951
Default Alt Text
D449.id1087.diff (9 KB)
Attached To
Mode
D449: Allow to customize /auth route
Attached
Detach File
Event Timeline
Log In to Comment