I'm a bit frustrated over logging in using this code. I followed this tutorial - Laravel authentication, logging in.
This is my register page:
@extends('layouts.master')
@section('title')
Create User
@stop
<link href="{!! asset('css/style.css') !!}" media="all" rel="stylesheet" type="text/css" />
@section('body')
{!! Form::open(array('action' => 'UserController@store')) !!}
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<DIV align="center"><SPAN class="div-header">MEMBER REGISTRATION</SPAN></DIV>
<TABLE>
<TH>FIELDS</TH><TH>DESCRIPTIONS</TH>
<TR><TD>{!! Form::text('firstname', '', ['class'=>'css-input', 'placeholder'=>'enter firstname' ]) !!}</TD><TD class="font-description"><SPAN><STRONG><I>FIRSTNAME</I></STRONG></SPAN> field requests the input of your surname or family name. Only <SPAN><STRONG><I>alphabets</I></STRONG></SPAN> are accepted as valid inputs. </TD></TR>
<TR><TD>{!! Form::text('lastname', '', ['class'=>'css-input', 'placeholder'=>'enter lastname']) !!}</TD><TD class="font-description"><SPAN><STRONG><I>LASTNAME</I></STRONG></SPAN> field requests the input of your real or given name, not a nickname. Only <SPAN><STRONG><I>alphabets</I></STRONG></SPAN> are accepted as valid inputs. </TD></TR>
<TR><TD>{!! Form::email('email', '', ['class'=>'css-input', 'placeholder'=>'myemail@domain.com']) !!}</TD><TD class="font-description"><SPAN><STRONG><I>EMAIL</I></STRONG></SPAN> field requests the input of your email address, It must have been opened before this registration can be effected. If you intend opening, kindly open a <a href="http://ift.tt/1N41MGn">Gmail</a>, <a href="http://ift.tt/1XzaTcv">Yahoo</a> , <a href="http://ift.tt/1N41MGp">Microsoft</a> or any other one as appropriate.</TD></TR>
<TR><TD>{!! Form::text('username', '', ['class'=>'css-input', 'placeholder'=>'my username']) !!}</TD><TD class="font-description"><SPAN><STRONG><I>USERNAME</I></STRONG></SPAN> field requests the input of a nickname or any other name you with to be referred with. Only <SPAN><STRONG><I>alphabets and figures</I></STRONG></SPAN> are accepted as valid inputs.</TD></TR>
<TR><TD>{!! Form::password('password', ['class'=>'css-input', 'placeholder'=>'password']) !!}</TD><TD class="font-description"><SPAN><STRONG><I>PASSWORD</I></STRONG></SPAN> field requests the input of a chosen secret code. A minimum of 8 characters is adviced for a secure account. A combination of<SPAN><STRONG><I> alphabets, figures and special characters</I></STRONG></SPAN> are accepted as valid inputs.</TD></TR>
<TR><TD>{!! Form::password('password_confirmation', ['class'=>'css-input', 'placeholder'=>'repeat password']) !!}</TD><TD class="font-description"><SPAN><STRONG><I>REPEAT PASSWORD</I></STRONG></SPAN> field requests the re-input of the password above. A minimum of 8 characters is adviced for a secure account. A combination of<SPAN><STRONG><I> alphabets, figures and special characters</I></STRONG></SPAN> are accepted as valid inputs.</TD></TR>
<TR><TD>{!! Form::submit('SUBMIT', ['class'=>'css-button']) !!}</TD><TD><div id="divContainer"><div class="theDiv">{!! Form::submit('FACEBOOK', ['class'=>'css-viewdetailbutton']) !!}</div><div class="theDiv">{!! Form::submit('YAHOO', ['class'=>'css-updatebutton']) !!}</div><div class="theDiv">{!! Form::submit('GOOGLE', ['class'=>'css-deletebutton']) !!}</div></div><div class="theDiv">{!! Form::submit('PASSWORD REC', ['class'=>'css-deletebutton']) !!}</div></TD></TR>
</TABLE>
{!! Form::close() !!}
@stop
The routes:
Route::resource('users', 'UserController');
Route::get('auth/login/{confirmationCode}', ['as' => 'verifypage', 'uses' => 'UserController@confirm']);
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');
The controller:
public function loginUser()
{
$rules = [
//'username' => 'required|exists:users',
'email' => 'required|exists:users',
'password' => 'required'
];
$input = Input::only('username', 'email', 'password');
$validator = Validator::make($input, $rules);
if($validator->fails())
{
return Redirect::back()->withInput()->withErrors($validator);
}
$credentials = [
// 'username' => Input::get('username'),
'email' => Input::get('email'),
'password' => Input::get('password'),
'confirmed' => 1
];
if ( ! Auth::attempt($credentials))
{
return Redirect::back()
->withInput()
->withErrors([
'credentials' => 'We were unable to sign you in.'
]);
}
Flash::message('Welcome back!');
//return Redirect::index();
return view('userpages.index');
}
This code executed but only keeps giving routing problems. I'm surprised it can't find the index page or I'm doing something wrong. It executed because i can see in the db the value of confirmed column changed to 1 in the db. What exactly I'm i doing wrong. I appreciate your valid input. Please , exact code snippet will be appreciated. m getting]2]2
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire