Laravel 5.6提交表格后下载php / html文件

时间:2018-06-14 05:43:03

标签: php laravel authentication laravel-5.6 http-status-code-503

我正在使用laravel 5.6,我已经从laravel添加了auth。

有时当我尝试使用chrome(最新版本)登录时,我会下载文件。

该档案的内容如下: -

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>503 Service Unavailable</title>
</head><body>
<h1>Service Unavailable</h1>
<p>The server is temporarily unable to service your
request due to maintenance downtime or capacity
problems. Please try again later.</p>
</body></html>
但网站没有下降或什么的。另一个人可以登录。

你有什么想法吗?

我在终端上安装了auth:

php artisan make:auth

路线:

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', 'Controller@welcome')->name('welcome');
Route::get('/projects', 'Controller@projects')->name('projects');
Route::get('/news', 'Controller@news')->name('news');
Route::get('/angelo', 'Controller@angelo')->name('angelo');
Route::get('/nils', 'Controller@nils')->name('nils');
Route::get('/eike', 'Controller@eike')->name('eike');
Route::get('/impressum', 'Controller@impressum')->name('impressum');
Route::get('/agbs', 'Controller@agb')->name('agb');
Route::get('/privacy', 'Controller@privacy')->name('privacy');

//Route::get('/aboutUs', 'Controller@aboutUs')->name('aboutUs');
//Route::get('/team', 'Controller@team')->name('team');
//Route::get('/test', 'Controller@test')->name('test');

Auth::routes();

//Route::get('/verify-user/{code}', 'Auth\RegisterController@activateUser')->name('activate.user');

Route::get('/home', 'HomeController@index')->name('home');

Route::get('home/allUser', 'AdminController@allUser')->name('allUser');
Route::get('home/allUser/{id}/edit', 'AdminController@allUserEdit')->name('allUserEdit');
Route::get('home/privacy', 'AdminController@privacy')->name('privacy');
Route::get('home/privacy/{id}/edit', 'AdminController@privacyEdit')->name('privacyEdit');
Route::get('home/privacy/new', 'AdminController@privacyNew')->name('privacyNew');
Route::get('home/agbs', 'AdminController@agbs')->name('agbs');
Route::get('home/agbs/{id}/edit', 'AdminController@agbsEdit')->name('agbsEdit');
Route::get('home/agbs/new', 'AdminController@agbsNew')->name('agbsNew');
Route::get('home/customers', 'AdminController@customers')->name('customers');
Route::get('home/customers/{id}/edit', 'AdminController@customersEdit')->name('customersEdit');
Route::get('home/customers/new', 'AdminController@customersNew')->name('customersNew');

Route::get('/logout', '\App\Http\Controllers\Auth\LoginController@logout');


Route::post('privacyUpdate', 'AdminController@privacyUpdate')->name('privacyUpdate');
Route::post('privacySave', 'AdminController@privacySave')->name('privacySave');
Route::post('agbsUpdate', 'AdminController@agbsUpdate')->name('agbsUpdate');
Route::post('agbsSave', 'AdminController@agbsSave')->name('agbsSave');

Route::post('customersUpdate', 'AdminController@customersUpdate')->name('customersUpdate');
Route::post('upload', 'AdminController@uploadSubmit')->name('uploadSubmit');
Route::post('customersSave', 'AdminController@customersSave')->name('customersSave');

用户模型: -

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'firstname','lastname', 'email', 'password'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function roles() {
        return $this->belongsToMany(Role::class);
    }

    /**
    * @param string|array $roles
    */
    public function authorizeRoles($roles) {
        if (is_array($roles)) {
            return $this->hasAnyRole($roles) || 
                abort(401, 'This action is unauthorized.');
        }
        return $this->hasRole($roles) || 
            abort(401, 'This action is unauthorized2.');
    }

    /**
    * Check multiple roles
    * @param array $roles
    */
    public function hasAnyRole($roles) {
        return null !== $this->roles()->whereIn('name', $roles)->first();
    }

    /**
    * Check one role
    * @param string $role
    */
    public function hasRole($role){
        return null !== $this->roles()->where('name', $role)->first();
    }

}

角色模型:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
    public function users() {
        return $this->belongsToMany(User::class);
    }
}

登录控制器:

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Auth;
use Illuminate\Http\Request;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }

    public function logout(Request $request) {
        Auth::logout();
        return redirect('/login');
      }
}

观点:

@extends('homepage.layouts.app')

@include('homepage.elements.navigation1')

@section('content')
<section id="login">
    <div class="row">
        <div class="container">
            <div class="row">
            </div>
            <div class="row">
                <div class="col">
                    <div class="background-letters top-buffer02">
                        {!! __('nerdlab.bgLogin') !!}
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-6 offset-lg-3 px-4">
                    <div class="basic-headline">
                        {!! __('nerdlab.loginHead') !!}
                    </div>
                    <div class="empty-space"></div>
                    <div class="magenta-line"></div>
                    <div class="empty-space-bot"></div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-6 offset-lg-3 px-4">
                    <div class="basic-text">
                        {!! __('nerdlab.loginText') !!}
                        <br>
                        <br>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="container">
            <div class="col-lg-6 offset-lg-3 px-4">
                <form class="form-signin" method="POST" action="{{ route('login') }}">
                    @csrf
                    <div class="form-label-group formular">
                        <input type="email" name="email" id="email" value="{{ old('email') }}" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" placeholder="{!! __('nerdlab.loginInput01') !!}" required="" autofocus="" autocomplete="off">
                        @if ($errors->has('email'))
                            <span class="invalid-feedback">
                                <strong>{{ $errors->first('email') }}</strong>
                            </span>
                        @endif
                    </div>
                    <div class="form-label-group formular">
                        <input type="password" id="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" placeholder="{!! __('nerdlab.loginInput02') !!}" required="" name="password" autocomplete="off">
                        @if ($errors->has('password'))
                            <span class="invalid-feedback">
                                <strong>{{ $errors->first('password') }}</strong>
                            </span>
                        @endif
                    </div>
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" name="remember-me" {{ old('remember-me') ? 'checked' : '' }}><span class="basic-text">{!! __('nerdlab.loginCheck01') !!}</span>
                        </label>
                    </div>
                    <button class="btn btn-primary" type="submit">{!! __('nerdlab.buttonLogin') !!}</button>
                    <div class="center-elements">
                        <a href="{{ route('register') }}">{!! __('nerdlab.loginRedirect') !!}</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
@endsection


@section('javascript')
@endsection

access.log为long for stackoverflow。

access.log

0 个答案:

没有答案