php - Laravel 5 - how to authenticate without email confirmation? -
i'm creating simple authentication system in laravel 5. have authentication code written in laravel 4 i'm using foundation.
my problem is,
sqlstate[42s22]: column not found: 1054 unknown column 'confirmed' in 'where clause' (sql: select *
users
confirmed
= 1 limit 1)
it looks laravel looking see if email verified. not need implement sign-up , verification process application. question is, how tell laravel not worry email confirmation?
my authentication code looks this:
public function postauthenticate() { // fetch posted credentials $email = \request::input('email'); $password = \request::input('password'); $remember = \request::has('_remember'); $credentials = [ 'email' => $email, 'password' => $password, 'confirmed' => 1 ]; // attempt log in user if (\auth::attempt($credentials, $remember)) { return \redirect::intended('dashboard'); } // if code reached, means user failed authenticated. // in case, redirect login page errors. $messages = new illuminate\support\messagebag; $messages->add('authentication error', 'sign in failed.'); return \redirect::to('/login') ->withinput() ->with('errors', $messages); }
and user model looks like:
<?php namespace app; use illuminate\auth\authenticatable; use illuminate\database\eloquent\model; use illuminate\auth\passwords\canresetpassword; use illuminate\contracts\auth\authenticatable authenticatablecontract; use illuminate\contracts\auth\canresetpassword canresetpasswordcontract; class user extends model implements authenticatablecontract, canresetpasswordcontract { use authenticatable, canresetpassword; /** * database table used model. * * @var string */ protected $table = 'users'; /** * attributes mass assignable. * * @var array */ protected $fillable = ['name', 'email', 'password']; /** * attributes excluded model's json form. * * @var array */ protected $hidden = ['password', 'remember_token']; }
and finally, user table migration is:
<?php use illuminate\database\schema\blueprint; use illuminate\database\migrations\migration; class createuserstable extends migration { /** * run migrations. * * @return void */ public function up() { schema::create('users', function(blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password', 60); $table->remembertoken(); $table->timestamps(); }); } /** * reverse migrations. * * @return void */ public function down() { schema::drop('users'); } }
thanks!
you have remove 'confirmed' => 1
$credentials
.
for example:
$credentials = [ 'email' => $email, 'password' => $password ];
Comments
Post a Comment