allow to login even update is pending

This commit is contained in:
Pig Fang 2020-04-01 16:31:34 +08:00
parent 67f2d513ea
commit afd7ea993b
4 changed files with 20 additions and 6 deletions

View File

@ -23,6 +23,8 @@ class RedirectToSetup
$user = $request->user();
if ($user && $user->isAdmin()) {
return redirect('/setup/update');
} elseif ($request->is('auth/login')) {
return $next($request);
} else {
abort(503);
}

View File

@ -5,6 +5,7 @@ namespace App\Providers;
use App\Http\View\Composers;
use App\Services\Webpack;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
use View;
class ViewServiceProvider extends ServiceProvider
@ -66,12 +67,13 @@ class ViewServiceProvider extends ServiceProvider
View::composer('shared.foot', Composers\FootComposer::class);
View::composer(['errors.*', 'setup.*'], function ($view) use ($webpack) {
$view->with([
'styles' => [
$webpack->url('spectre.css'),
],
'scripts' => [],
]);
// @codeCoverageIgnoreStart
if (Str::startsWith(config('app.asset.env'), 'dev')) {
$view->with(['scripts' => [$webpack->url('spectre.js')]]);
} else {
$view->with('styles', [$webpack->url('spectre.css')]);
}
// @codeCoverageIgnoreEnd
});
View::composer('auth.oauth', function ($view) {

View File

@ -3,7 +3,16 @@
{% block title %}503 Service Unavailable{% endblock %}
{% block message %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.13.0/css/all.min.css">
<p>
{{ trans('errors.exception.detail', {msg: exception.message ?: trans('errors.http.msg-503')}) }}
</p>
{% if not auth_check() %}
<div class="mt-5">
<a href="{{ url('/auth/login') }}" class="btn btn-primary">
<i class="icon fas fa-sign-in-alt mr-1"></i>
{{ trans('general.login') }}
</a>
</div>
{% endif %}
{% endblock %}

View File

@ -17,6 +17,7 @@ class RedirectToSetupTest extends TestCase
$current = config('app.version');
config(['app.version' => '100.0.0']);
$this->get('/')->assertStatus(503);
$this->get('/auth/login')->assertViewIs('auth.login');
$this->actingAs($superAdmin)->get('/')->assertRedirect('/setup/update');
config(['app.version' => $current]);