Support the ongoing development of Laravel.io →
Authentication Forms Validation
Last updated 2 years ago.
0

Is the password in the database hashed? That or a validation error are the only reasons that code would fail.

0

the password is hashed, should I hash the password from the the Input::get function

0

No, Auth::attempt hashes it for you.

Is it the 'Failed To Log In' message you are receiving?

What columns do you have in your database? Can you please post your user model?

0

I later added the id field using an external application. My User model has the default functions only. I recieve that 'Log in failed error'

  class CreateUsersTable extends Migration {

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
	Schema::create('users',  function(Blueprint $table){
                
                $table->string('name');
                $table->string('surname');
                $table->string('idNumber');
                $table->string('password');
                $table->string('email');
                $table->integer('mobile_phone');
                $table->integer('home_phone');
                $table->date('dob');
                $table->text('address');
                $table->boolean('isStaff')->default(0);
                $table->boolean('isStudent')->default(0);
                $table->boolean('isAdmin')->default(0);
                $table->boolean('isExaminer')->default(0);
                $table->string('image');
                $table->timestamps();
                        
            });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
	Schema::drop('users');
}

}




class User extends Eloquent implements UserInterface, RemindableInterface {



/**
 * The database table used by the model.
 *
 * @var string
 */
protected $table = 'users';

/**
 * The attributes excluded from the model's JSON form.
 *
 * @var array
 */
protected $hidden = array('password', 'remember_token');
    
    //rules used to validate user
    public static $logInRules = array('username' =>'required',
                                 'password' => 'required');
    
    
    protected $fillable = array('name', 'surname', 'idNumber', 'email','mobile_phone','home_phone','dob','address','isStaff','isStudent','isAdmin','isExaminer');
    
        
     
     
public function getAuthIdentifier() {
    
}

public function getAuthPassword() {
    
}

public function getRememberToken() {
    
}

public function getRememberTokenName() {
    
}

public function getReminderEmail() {
    
}

public function setRememberToken($value) {
    
}

}
Last updated 9 years ago.
0

You've defined that you're implementing UserInterface and RemindableInterface but you haven't implemented the functions for those interfaces.

These are the culprits:

public function getAuthIdentifier() {

}

public function getAuthPassword() {

}

Instead of implementing those interface functions yourself you should use the UserTrait and RemindableTrait per the bundled user model:

https://github.com/laravel/laravel/blob/ba0cf2a1c9280e99d39aad5d4d686d554941eea1/app/models/User.php

use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {
	use UserTrait, RemindableTrait;

	/* ... */
}
Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

andyblem andyblem Joined 7 Nov 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.