Piwik\Plugins\UsersManager\API::getUserLoginFromUserEmail PHP Метод

getUserLoginFromUserEmail() публичный Метод

Returns the first login name of an existing user that has the given email address. If no user can be found for this user an error will be returned.
public getUserLoginFromUserEmail ( string $userEmail ) : boolean
$userEmail string
Результат boolean true if the user is known
    public function getUserLoginFromUserEmail($userEmail)
    {
        Piwik::checkUserIsNotAnonymous();
        Piwik::checkUserHasSomeAdminAccess();
        $this->checkUserEmailExists($userEmail);
        $user = $this->model->getUserByEmail($userEmail);
        // any user with some admin access is allowed to find any user by email, no need to filter by access here
        return $user['login'];
    }

Usage Example

Пример #1
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage checkUserHasSomeAdminAccess Fake exception
  */
 public function testGetUserLoginFromUserEmail_shouldThrowException_IfUserDoesNotHaveAtLeastAdminPermission()
 {
     FakeAccess::clearAccess($superUser = false, $admin = array(), $view = array(1));
     $this->api->getUserLoginFromUserEmail('*****@*****.**');
 }