jeudi 19 mai 2016

laravel authentication and jenssegers-mongodb not working

Hello i am using laravel, mongoDB and AdminLTE template in my project. for mongoDB i am using jenssegers/laravel-mongodb. But now i am facing error when i creating login authentication in laravel controller this my code in AuthController.php

   public function postLogin(Request $request)
   {
    $authUser = User::where('email', '=', $request->email)->first();
    if (isset($authUser)) {
        if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
            echo "success";exit;
        } else {
            echo "fail";exit;
        }
    } else {
        echo "fail";exit;
    }

In User.php code

    <?php

namespace App;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use DB;

use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Auth\Authenticable as AuthenticableTrait;



class User extends Eloquent implements Authenticatable 
{
    protected $connection = 'mongodb';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
}

in User.php if i using only Eloquent like class User extends Eloquent so getting this error

Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\User given, called in /var/www/html/cams_alphaV1/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php on line 378 and defined

if i using class User extends Eloquent implements Authenticatable so getting this error

Class App\User contains 6 abstract methods and must therefore be declared abstract or implement the remaining methods (Illuminate\Contracts\Auth\Authenticatable::getAuthIdentifierName, Illuminate\Contracts\Auth\Authenticatable::getAuthIdentifier, Illuminate\Contracts\Auth\Authenticatable::getAuthPassword, ...)

please help me i am totally stuck.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1NA6txZ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire