突然我的登录工作无法正常工作,无法对我的用户进行身份验证,但是如果我注册了一个新用户,那么我就登录了authomatic我只是改变了路线但是如果我仍然无法使用它回滚。
routes.php文件:
//pagina inicial
Route::get('/', 'PublicController@welcome');
//hilos
Route::get('/seccion/{subboaName}', 'ThreadController@index');
Route::post('/seccion/{subboaName}', 'ThreadController@store');
Route::get('/thread/{img}', 'ThreadController@mostrarImagen');
//Invitaciones
Route::get('/administrar/invitaciones', 'invitacionController@index');
Route::get('/administrar/invitacion/{id}', 'invitacionController@mostrarInvitacion');
Route::delete('/administrar/invitacion/{id}', 'invitacionController@eliminarInvitacion');
Route::post('/administrar/invitacion', 'invitacionController@invitacion');
//Secciones
Route::get('/administrar/secciones', 'BoardController@index');
Route::get('/administrar/seccion/{id}', 'BoardController@mostrarSeccion');
Route::delete('/administrar/seccion/{id}', 'BoardController@eliminarSeccion');
Route::post('/administrar/secciones', 'BoardController@seccion');
//Subsecciones
Route::get('/administrar/subsecciones', 'SubboardController@index');
Route::get('/administrar/subseccion/{id}', 'SubboardController@mostrarSubseccion');
Route::delete('/administrar/subseccion/{id}', 'SubboardController@eliminarSubseccion');
Route::post('/administrar/subsecciones', 'SubboardController@subseccion');
//usuarios
Route::auth();
中间件/ Authenticate.php
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class Authenticate
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->guest()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('ingresar');
}
}
return $next($request);
}
}
login.blade.php:
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-heading">Ingresar</div>
<div class="panel-body">
<form class="form col-md-12 center-block" role="form" method="POST" action="{{ url('/ingresar') }}">
{!! csrf_field() !!}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<input type="text" class="form-control input-lg" placeholder="Nombre de usuario" name="name" value="{{ old('name') }}">
@if ($errors->has('name'))
<p class="help-block">
<div class="alert alert-danger" role="alert">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
<span class="sr-only">Error:</span>
{{ $errors->first('name') }}
</div>
</p>
@endif
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<input type="password" class="form-control input-lg" placeholder="Contraseña" name="password">
@if ($errors->has('password'))
<p class="help-block">
<div class="alert alert-danger" role="alert">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
<span class="sr-only">Error:</span>
{{ $errors->first('password') }}
</div>
</p>
@endif
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox" name="remember"> Recordarme
</label>
</div>
</div>
<div class="form-group">
<div class="form-group">
<button type="submit" class="btn btn-default btn-lg btn-block">
Ingresar
</button>
</div>
</div>
<div class="form-group text-center">
<a class="btn btn-link" href="{{ url('/password/reset') }}">¿Has olvidado tu contraseña?</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
AuthController.php
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Invite;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/';
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:25|unique:users',
'email' => 'required|email|max:255|unique:users|exists:invites',
'password' => 'required|min:6|confirmed',
'password_confirmation' => 'required|min:6',
'invite' => 'required|exists:invites,code',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
Invite::where('email', $data['email'])->delete();
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
供应商/ laravel /框架/ SRC /照亮/路由/ Router.php:
public function auth()
{
// Authentication Routes...
$this->get('ingresar', 'Auth\AuthController@showLoginForm');
$this->post('ingresar', 'Auth\AuthController@login');
$this->get('salir', 'Auth\AuthController@logout');
// Registration Routes...
$this->get('registrar', 'Auth\AuthController@showRegistrationForm');
$this->post('registrar', 'Auth\AuthController@register');
// Password Reset Routes...
$this->get('password/reset/{token?}', 'Auth\PasswordController@showResetForm');
$this->post('password/email', 'Auth\PasswordController@sendResetLinkEmail');
$this->post('password/reset', 'Auth\PasswordController@reset');
}
答案 0 :(得分:0)
解决了它,默认laravel尝试比较一个电子邮件而不是一个名字,所以当我更新laravel我的文件被覆盖并且无法正常工作
答案 1 :(得分:0)
我也遇到了同样的问题。当我重新启动Apache时,它起作用了。请先重新启动Apache,然后再研究代码。