Locker\Helpers\Helpers::getUserPassFromBAuth PHP Method

getUserPassFromBAuth() static public method

Gets the Client/Lrs username and password from the Basic Auth authorization string.
static public getUserPassFromBAuth ( String $authorization ) : [String]
$authorization String
return [String]
    static function getUserPassFromBAuth($authorization)
    {
        $username = json_decode('"' . \LockerRequest::getUser() . '"');
        $password = json_decode('"' . \LockerRequest::getPassword() . '"');
        return [$username, $password];
    }

Usage Example

 /**
  * Gets the username and password from the authorization string.
  * @return [String] Formed of [Username, Password]
  */
 static function getUserPassFromAuth()
 {
     $authorization = \LockerRequest::header('Authorization');
     if ($authorization !== null && strpos($authorization, 'Basic') === 0) {
         list($username, $password) = Helpers::getUserPassFromBAuth($authorization);
     } else {
         if ($authorization !== null && strpos($authorization, 'Bearer') === 0) {
             list($username, $password) = Helpers::getUserPassFromOAuth($authorization);
         } else {
             throw new Exceptions\Exception('Invalid auth', 400);
         }
     }
     return [$username, $password];
 }