AuthBucket\OAuth2\GrantType\PasswordGrantTypeHandler::checkUsername PHP 메소드

checkUsername() 개인적인 메소드

Fetch username from POST.
private checkUsername ( Request $request ) : string
$request Symfony\Component\HttpFoundation\Request Incoming request object
리턴 string The supplied username
    private function checkUsername(Request $request)
    {
        // username must exist and in valid format.
        $username = $request->request->get('username');
        $errors = $this->validator->validate($username, [new NotBlank(), new Username()]);
        if (count($errors) > 0) {
            throw new InvalidRequestException(['error_description' => 'The request includes an invalid parameter value.']);
        }
        // password must exist and in valid format.
        $password = $request->request->get('password');
        $errors = $this->validator->validate($password, [new NotBlank(), new Password()]);
        if (count($errors) > 0) {
            throw new InvalidRequestException(['error_description' => 'The request includes an invalid parameter value.']);
        }
        // Validate credentials with authentication manager.
        try {
            $token = new UsernamePasswordToken($username, $password, 'oauth2');
            $authenticationProvider = new DaoAuthenticationProvider($this->userProvider, new UserChecker(), 'oauth2', $this->encoderFactory);
            $authenticationProvider->authenticate($token);
        } catch (BadCredentialsException $e) {
            throw new InvalidGrantException(['error_description' => 'The provided resource owner credentials is invalid.']);
        }
        return $username;
    }
PasswordGrantTypeHandler