Now when i register a user i get redirected to /home page, but when i do like Jeff and "logout" the user and get redirected back to /home (which isn't there yet), all of that is fine, but then when i want to go to /auth/register, i get redirected back to /home instantly, i tried a couple of things, and then i tried deleting the user manually using tinker, only then i can go to /auth/register, and then the same problem again, i get stuck at the /home page, i also changed the $redirectTo = '/articles'; , when i forwarded a bit in the video, i see that Jeff does this (\Auth::user();) to find the currently logged in user, i found that whenever i do this i always find the user that i registered is still logged in, unless i delete the user i created, the user is always logged in, the logout method isn't working, any ideas?
My AuthController:
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
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;
protected $redirectTo = '/articles';
/**
* Where to redirect users after login / registration.
*
* @var string
*/
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['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:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'username' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire