seregazhuk\PinterestBot\Api\Providers\Auth::login PHP Method

login() public method

Login as pinner.
public login ( string $username, string $password, boolean $autoLogin = true ) : boolean
$username string
$password string
$autoLogin boolean
return boolean
    public function login($username, $password, $autoLogin = true)
    {
        if ($this->request->isLoggedIn()) {
            return true;
        }
        $this->checkCredentials($username, $password);
        // Trying to load previously saved cookies from last login session for this username.
        // Then grab user profile info to check, if cookies are ok. If an empty response
        // was returned, then send login request.
        if ($autoLogin && $this->processAutoLogin($username)) {
            return true;
        }
        return $this->processLogin($username, $password);
    }

Usage Example

 /** @test */
 public function it_should_return_false_when_login_fails()
 {
     $this->setIsLoggedInExpectation(false);
     $this->request->shouldReceive('getHttpClient')->andReturn(new CurlHttpClient(new Cookies()));
     $this->apiShouldReturnError();
     $this->request->shouldReceive('clearToken');
     $this->assertFalse($this->provider->login('test', 'test', false));
 }