public function newTokenAction(Request $request, $userClass)
    {
        try {
            $this->get('bengor_user.' . $userClass . '.api_command_bus')->handle(
                new LogInUserCommand(
                    $request->getUser(),
                    $request->getPassword()
                )
            );
        } catch (UserDoesNotExistException $exception) {
            return new JsonResponse('', 400);
        } catch (UserEmailInvalidException $exception) {
            return new JsonResponse('', 400);
        } catch (UserInactiveException $exception) {
            return new JsonResponse('Inactive user', 400);
        } catch (UserPasswordInvalidException $exception) {
            return new JsonResponse('', 400);
        }
        $token = $this->get('lexik_jwt_authentication.encoder.default')->encode(['email' => $request->getUser()]);

        return new JsonResponse(['token' => $token]);
    }
public function newTokenAction(Request $request, $userClass)
    {
        try {
            $this->get('bengor_user.' . $userClass . '.api_command_bus')->handle(
                new LogInUserCommand(
                    $request->getUser(),
                    $request->getPassword()
                )
            );
        } catch (UserDoesNotExistException $exception) {
            return new JsonResponse('', 400);
        } catch (UserEmailInvalidException $exception) {
            return new JsonResponse('', 400);
        } catch (UserInactiveException $exception) {
            return new JsonResponse('Inactive user', 400);
        } catch (UserPasswordInvalidException $exception) {
            return new JsonResponse('', 400);
        }
        $token = $this->get('lexik_jwt_authentication.encoder.default')->encode(['email' => $request->getUser()]);

        return new JsonResponse(['token' => $token]);
    }
public function newTokenAction ( Request $ request , $ userClass ) { try { $ this -> get ( 'bengor_user.' . $ userClass . '.api_command_bus' ) -> handle ( new LogInUserCommand ( $ request -> getUser ( ) , $ request -> getPassword ( ) ) ) ; } catch ( UserDoesNotExistException $ exception ) { return new JsonResponse ( '' , 400 ) ; } catch ( UserEmailInvalidException $ exception ) { return new JsonResponse ( '' , 400 ) ; } catch ( UserInactiveException $ exception ) { return new JsonResponse ( 'Inactive user' , 400 ) ; } catch ( UserPasswordInvalidException $ exception ) { return new JsonResponse ( '' , 400 ) ; } $ token = $ this -> get ( 'lexik_jwt_authentication.encoder.default' ) -> encode ( [ 'email' => $ request -> getUser ( ) ] ) ; return new JsonResponse ( [ 'token' => $ token ] ) ; }
Generates new token action.

@param Request $request   The request
@param string  $userClass Extra parameter that contains the user type

@return \Symfony\Component\HttpFoundation\JsonResponse
Generates new token action .