mirror of
https://github.com/silverstripe/silverstripe-restfulserver
synced 2024-10-22 14:05:58 +02:00
29 lines
604 B
PHP
29 lines
604 B
PHP
|
<?php
|
||
|
|
||
|
namespace SilverStripe\RestfulServer\Tests\Stubs;
|
||
|
|
||
|
use SilverStripe\Dev\TestOnly;
|
||
|
use SilverStripe\Security\Member;
|
||
|
|
||
|
/**
|
||
|
* An unsecure test authenticator.
|
||
|
*/
|
||
|
class EmailOnlyAuthenticator implements TestOnly
|
||
|
{
|
||
|
/**
|
||
|
* @return Member|false
|
||
|
*/
|
||
|
public static function authenticate()
|
||
|
{
|
||
|
//if there is no username or password, fail
|
||
|
if (!isset($_SERVER['PHP_AUTH_USER'])) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
/** @var null|Member $member */
|
||
|
$member = Member::get()->find('Email', $_SERVER['PHP_AUTH_USER']);
|
||
|
|
||
|
return $member ?? false;
|
||
|
}
|
||
|
}
|