vendredi 3 juin 2016

Laravel 5.2 login doesn't work, no redirect and no errors

my Laravel login worked last week and now it doesn't (using the standard login generated by Laravel). I don't get an error message (wrong password, exceptions, anything). Every time I press "Login" it reloads the page. I have set the redirect to /member. Does anyone have an idea how to fix this?

Here are some files:

routes.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.
|
*/

if(env("APP_ENV") == "prod"){
    Route::get('/', function() {
        return view("pages.demo");
    });
} else {

    Route::get('/', 'PagesController@index');

    Route::group(['middleware' => ['loggedin']], function(){
        Route::get('member/', function(){
            return redirect('member/dashboard');
        });
        Route::get('member/dashboard', 'PagesController@dashboard');
        Route::get('member/tree', 'TreeController@displayTree');
        Route::get('member/statistics', 'PagesController@statistics');
        Route::get('member/link', 'PagesController@link');
        Route::get('member/advertising-tools', 'PagesController@advertising');
    });

    Route::get('/click/{idhash}', 'ClickController@clickHandler');



    //Route::get('/login', 'PagesController@login');
    //Route::get('/register', 'PagesController@register');
    Route::auth();
}

login.blade.php:

            <div>
                <h1>
                    <span class="navy">ReferralTree</span>
                    <br/>
                    Login
                </h1>
            </div>
            <br/>
            <div class="col-md-8 col-md-offset-2">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <form class="form-horizontal" role="form" method="POST" action="">
                            {!! csrf_field() !!}

                            <div class="form-group">
                                <label class="col-md-4 control-label">E-Mail Address</label>

                                <div class="col-md-6">
                                    <input type="user_email" class="form-control" name="user_email"
                                           value="">

                                    @if ($errors->has('user_email'))
                                        <span class="help-block">
                                        <strong></strong>
                                    </span>
                                    @endif
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-4 control-label">Password</label>

                                <div class="col-md-6">
                                    <input type="password" class="form-control" name="user_password">

                                    @if ($errors->has('user_password'))
                                        <span class="help-block">
                                        <strong></strong>
                                    </span>
                                    @endif
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-md-6 col-md-offset-4">
                                    <div class="checkbox">
                                        <label>
                                            <input type="checkbox" name="remember"> Remember Me
                                        </label>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-md-6 col-md-offset-4">
                                    <button type="submit" class="btn btn-primary">
                                        <i class="fa fa-btn fa-sign-in"></i>Login
                                    </button>

                                    <a class="btn btn-link" href="">Forgot Your
                                        Password?</a>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

AuthController.php:

<?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;

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 = '/member';

    /**
     * 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, [
            'user_firstname' => 'required|max:255',
            'user_lastname' => 'required|max:255',
            'user_email' => 'required|email|max:255|unique:users',
            'password' => 'required|min:6|confirmed',
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array $data
     * @return User
     */
    protected function create(array $data)
    {

        $cookie = request()->cookie('referrer');
        if($cookie != null) {
            $user_click_id = request()->cookie('referrer');
        } else {
            $user_click_id = 0;
        }

            $user_create = User::create([
                'user_firstname' => $data['user_firstname'],
                'user_lastname' => $data['user_lastname'],
                'user_email' => $data['user_email'],
                'user_password' => bcrypt($data['password']),
                'user_country' => $data['user_country'],
                'user_city' => $data['user_city'],
                'user_streetname' => $data['user_streetname'],
                'user_zipcode' => $data['user_zipcode'],
                'user_dob' => $data['user_dob'],
                'user_click_id' => $user_click_id,
                'user_registerip' => $_SERVER['REMOTE_ADDR']
            ]);



        $user_create->user_id_hash = md5($user_create->user_id);
        $user_create->save();

        return $user_create;
    }


    public function postLogin(Request $request)
    {
        $this->validate($request, [
            'user_email' => 'required|email', 'user_password' => 'required',
        ]);

        $credentials = $request->only('user_email', 'user_password');

        if ($this->auth->attempt($credentials, $request->has('remember'))) {
            return redirect()->intended($this->redirectPath());
        }

        return redirect($this->loginPath())
            ->withInput($request->only('user_email', 'remember'))
            ->withErrors([
                'user_email' => $this->getFailedLoginMessage(),
            ]);
    }
}

If you need more info I will post it here.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire