Beispiel #1
0
        public async Task LoginUserTestMustLogin()
        {
            LoginRequest request = new LoginRequest()
            {
                Email    = "*****@*****.**",
                Password = "******",
            };
            var result = await _authenticator.LoginUser(request);

            Assert.Equal(StatusCode.Ok, result.StatusCode);
            Assert.NotNull(result.Token);
        }
Beispiel #2
0
        public async Task <ActionResult <string> > Login([FromBody] LoginRequest formData)
        {
            var result = await _userManager.LoginUser(formData);

            var response = result.StatusCode;

            switch (response)
            {
            case ContractsService.StatusCode.InvalidArgument:
                return(BadRequest(result.ErrorMessage));

            case ContractsService.StatusCode.NotFound:
                return(BadRequest(result.ErrorMessage));

            case ContractsService.StatusCode.Ok:
                return(result.Token);

            default:
                return(BadRequest("Unknown error"));
            }
        }