Support the ongoing development of Laravel.io →
posted 9 years ago
Authentication

Got most of the errors fixed can't get my head around this...


ErrorException in CustomUserProvider.php line 24:
Argument 1 passed to App\Auth\CustomUserProvider::__construct() must be an instance of App\Auth\Webservice\AuthCheckApi, instance of App\User given, called in /Applications/MAMP/htdocs/forms/app/Providers/CustomAuthProvider.php on line 18 and defined

Part of CustomUserProvider.php


<?php namespace App\Auth;

use Illuminate\Contracts\Auth\User as UserContract;
use Illuminate\Contracts\Auth\UserProvider as UserProviderInterface;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Auth\GenericUser;

class CustomUserProvider implements UserProviderInterface {
	/**
  * External webservice for authentication
  */
  private $webservice;
   /**
  * The user object.
  */
  private $user;

    /**
  * Constructor
  *
  * @return void
  */
  public function __construct(\App\Auth\Webservice\AuthCheckApi $webservice)
  {
      $this->webservice = $webservice;
      $this->user = null;
  }

AuthCheckApi is part of this Api file....


<?php

namespace App\Auth\Webservice;

require_once('nusoap/nusoap.php');

class LimoApiBase{

    protected $_apiKey = "*********************";
    protected $_apiId = "***********************";
    protected $_client = null;
    protected $_wsdl = null;

    public function __construct(){
        //$this->_apiKey = $apiKey;
        $this->_client = new \nusoap_client($this->_wsdl, true);
    }

    public function getClient(){
        return $this->_client;
    }






*** Some functions removed ***





class AuthCheckApi extends LimoApiBase{

    public function __construct(){
        $this->_wsdl = "iService.asmx?wsdl";
        parent::__construct();
    }

    public function LoginAccount($user,$pass){
        $result = $this->_call('LoginAccount', array('apiId'=>$this->_apiId, 'apiKey'=>$this->_apiKey, 'userName'=>$user, 'password'=>$pass));

        if ($result['ResponseText']=="OK") {
            return true;
        }else{
            return false;
        }
    }
    public function find($id){
        $result = $this->_call('ByAcctId', array('apiId'=>$this->_apiId, 'apiKey'=>$this->_apiKey, 'acctId'=>$id));

        if ($result['ResponseText']=="OK") {
                $userInfo= $result['Accounts']['AccountInfo'];
                
                $userReturn['id'] = $userInfo['AcctID'];
                $userReturn['user'] = $userInfo;
                return $userReturn;
                /*
                return $user = array(
                    'id' => $userInfo['AcctID'],
                    'email' => $userInfo['Email1'],
                    'FirstName' => $userInfo['FirstName'],
                    'LastName' => $userInfo['LastName'],
                );*/
        }else{
                return false;
        }
    }

    public function byusername($user,$pass){
        $result = $this->_call('LoginAccount', array('apiId'=>$this->_apiId, 'apiKey'=>$this->_apiKey, 'userName'=>$user,'password'=>$pass));
        if ($result['ResponseText']=="OK") {
              $userInfo1= $this->find($result['AcctId']);
              $userInfo2= array('username'=>$user);
            return  array_merge($userInfo1,$userInfo2);
        }else{
                return false;
        }
    }

    public function validateCredentials($user,$cred){
        if ($user->username==$cred) {
            return true;
        }else{
            return false;
        }
    }


}

Thanks in advance for any help

Last updated 2 years ago.
0

Got it working and Auth::check() passes as well but I get no value using Auth::id();

Very strange :|

0

Sign in to participate in this thread!

Eventy

Your banner here too?

nomie7 nomie7 Joined 2 Dec 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.

© 2025 Laravel.io - All rights reserved.