ollieread/multiauth

Undefined index: 'password'

hughsmith10 opened this issue · 2 comments

I am trying to authenticate a user against the "api_token" column in the db (not password). To do so, I am trying to run the following line of code:

Auth::legacy()->once(array("api_token"=>$api_token));

I get the following error:

[2014-04-30 12:10:54] local.ERROR: exception 'ErrorException' with message 'Undefined index: password' in /Users/hs/Sites/blueroof/br360/www/vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php:135

I am using the "database" driver and table "user".

return array(

'multi' => array(

    /*
    |--------------------------------------------------------------------------
    | Default Authentication Drivers (FOR MULTIPLE DATABASES)
    |--------------------------------------------------------------------------
    |
    | This option controls the authentication driver that will be utilized.
    | This drivers manages the retrieval and authentication of the users
    | attempting to get access to protected areas of your application.
    |
    | Supported: "database", "eloquent"
    |
    */

    'user' => array(

        'driver' => 'eloquent'

        /*
        |--------------------------------------------------------------------------
        | Authentication Model
        |--------------------------------------------------------------------------
        |
        | When using the "Eloquent" authentication driver, we need to know which
        | Eloquent model should be used to retrieve your users. Of course, it
        | is often just the "User" model but you may use whatever you like.
        |
        */

        ,'model' => 'User' //this ultimately maps to the "users" table

    )

    ,'legacy' => array(

        'driver' => 'database'

        /*
        |--------------------------------------------------------------------------
        | Authentication Table
        |--------------------------------------------------------------------------
        |
        | When using the "Database" authentication driver, we need to know which
        | table should be used to retrieve your users. We have chosen a basic
        | default value but you may easily change it to any table you like.
        |
        */

        //,'model' => 'User' //not needed for database authentication
        ,'table' => 'user'
    )

)

/*
|--------------------------------------------------------------------------
| Password Reminder Settings
|--------------------------------------------------------------------------
|
| Here you may set the settings for password reminders, including a view
| that should be used as your password reminder e-mail. You will also
| be able to set the name of the table that holds the reset tokens.
|
| The "expire" time is the number of minutes that the reminder should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/

, 'reminder' => array(

    'email' => 'emails.auth.reminder'

    ,'table' => 'password_reminders'

    ,'expire' => 60

));

Does "multiform" use the values from the database set in config defaults?

Config::get('database.default');

Any ideas Ollie?

Thanks again for your help on this.

The Auth library or even my Multiauth won't do for api authentication. Firstly because it expects a password credential, and secondly because it's not stateless.

I see... I didn't realize Auth required "password" as a field in the db.

Thanks.