samedi 24 octobre 2015

Laravel 5 authentication on home page

I have tried authentication before, but it has always been with views in my auth folder. I am now doing something different and cant seem to get it working. So I have this route which displays my homepage

Route::get('/', function () {
    return view('index');
});

On my homepage, I have my register and login forms. I wont show everything, but my register form looks like the following

<form class="form-horizontal" role="form" method="POST" action="/">
    <input type="hidden" name="_token" value="{{ csrf_token() }}">
    <div class="form-group">
        <div class="col-md-12">
            <input type="text" class="form-control" name="first_name" value="{{ old('first_name') }}" placeholder="First Name">
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-12">
            <input type="text" class="form-control" name="last_name" value="{{ old('last_name') }}" placeholder="Last Name">
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-12">
            <input type="email" class="form-control" name="email" value="{{ old('email') }}" placeholder="Email">
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-12">
            <input type="password" class="form-control" name="password" placeholder="Password">
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-12">
            <input type="password" class="form-control" name="password_confirmation" placeholder="Confirm Password">
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-12">
            <button type="submit" class="btn btn-primary">
                Register
            </button>
        </div>
    </div>
</form>

I then tried adding my routes for the registration

Route::get('/register', 'Auth\AuthController@getRegister');
Route::post('/register', 'Auth\AuthController@postRegister');

Because this is using the built in authentication, looking at the Traits, things like getRegister return a view in the auth folder. So in my AuthController, I have added

 public function getRegister()
 {
     return view('/');
 }

However, if I try to register, I still get a MethodNotAllowedHttpException.

What would be the stages I need to go through in order to get registration and login onto my homepage?

Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1LtXd9N
via IFTTT

Aucun commentaire:

Enregistrer un commentaire