ollieread / multiauth

Laravel multi auth
441 stars 109 forks source link

'ErrorException' with message 'Undefined index: password' #92

Closed Sajib32 closed 9 years ago

Sajib32 commented 9 years ago

// auth.php

'multi' => array(
    'jobseeker' => array(
        'driver' => 'eloquent',
        'model' => 'Jobseeker',
        'table' => 'jobseekers'
    ),
    'employer' => array(
        'driver' => 'eloquent',
        'model' => 'Employer',
        'table' => 'employers'
    )
),

// Jobseeker.php model file // <?php

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

class Jobseeker extends Eloquent implements UserInterface, RemindableInterface {

use UserTrait, RemindableTrait; protected $fillable = ['fullname','mothersname','fathersname','gender', 'marital','religion','dateofbirth','nationalid','email', 'userpassword', 'password_temp', 'code', 'active'];

protected $table = 'jobseekers';

public function getAuthPassword() 
{
    return $this->userpassword;
}

}

// JobseekerController

public function postSignIn() { $validator = Validator::make(Input::all(), array( 'email' => 'required|email', 'userpassword' => 'required' ) );

    if($validator->fails()) {
        return Redirect::route('jobseeker-sign-in')
               ->withErrors($validator)
               ->withInput();
    } else {

        Config::set('auth.model', 'Jobseeker');
        $auth = Auth::jobseeker()->attempt(array(
            'email' => Input::get('email'),
            'userpassword' => Input::get('userpassword'),
            'active' => 1
        ));

        if($auth) {
            // Redirect to the intended page
            return View::make('jobseeker.home');
        } else {
            return Redirect::route('jobseeker-sign-in')
           ->with('global', 'Email/password wrong, or account not activated.');
        }
    }

    return Redirect::route('jobseeker-home')
           ->with('global', 'There was a problem signing in you.');
}

This error shows:: production.ERROR: exception 'ErrorException' with message 'Undefined index: password' in H:\xampp\htdocs\myjobportal\vendor\laravel\framework\src\Illuminate\Auth\EloquentUserProvider.php:106 Stack trace: why does it show??? I dont know what should i do, plz help me....in which part i have to change...

ollieread commented 9 years ago

Your password field should be called password, that's a constraint from core laravel.

Sajib32 commented 9 years ago

tnx....@olliread...