I'm working on a Laravel authentication system, and while registration works and logs the user in, and creates entries in the database, but login doesn't do anything. I've included the Laravel project folder zipped on Google drive so you can look at any potential causes short of server configuration directly if you set up your own database. Note that this problem existed before I added jQuery mobile, so it's not AJAX loads.
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
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;
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'getLogout']);
}
protected $redirectPath = '/product';
/**
* 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([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
And routes.php:
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
/*Route::get('/', function () {
return view('welcome');
});*/
Route::get('/', 'WelcomeController@index');
Route::get("home", function (){ return view('welcome');} );
Route::get("checkuser", function() {return Auth::user(); });
//Route::get('product', 'WelcomeController@product');
//Route::controller('WelcomeController');
//product routes
Route::get("products", 'ProductController@products');
Route::get("product/{id}", 'ProductController@product');
// Authentication routes...
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');
// Registration routes...
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');
login.blade.php:
@extends('master.master')
@section('content')
<div id='login-form'>
<form method="POST" action='{!! url("auth/register")!!}' data-ajax="false">
{!! csrf_field() !!}
<div id='emailBox'>
<label for='email'>Email:</label>
<input name='email' id='email' type='email' value="{{ old('email') }}"/>
</div>
<div id='passBox'>
<label for='password'>Password</label>
<input name='password' id='password' type='password' />
</div>
<div id='rememberBox'>
<label for='remember'>Remember Me!</label>
<input name='remember' id='remember' type='checkbox' />
</div>
<div id='loginBox'>
<input type="submit" value="Log In!" id='loginButton' class='cloudButton'>
</div>
</form>
</div>
@stop
register.blade.php:
@extends('master.master')
@section('content')
<div id='register'>
<form method="post" action='{!! url("auth/register")!!}' data-ajax="false">
{!! csrf_field() !!}
<div id='nameBox'>
<label for='name'>First Name:</label> <input name='name' id='name'
type='text'>
</div>
<div id='emailBox'>
<label for='email'>Email:</label> <input name='email' id='email'
type='email' value="{{ old('email') }}" />
</div>
<div id='passBox'>
<label for='password'>Password:</label> <input name='password'
id='password' type='password' />
</div>
<div id="confirmBox">
<label for='password'>Confirm Password:</label>
<input type="password" name="password_confirmation">
</div>
<div id='signUpBox'>
<input type="submit" value="Sign Up!" id='signUpButton' class='cloudButton'>
</div>
</form>
</div>
@stop
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire