Esempio n. 1
0
        public async Task RegisterUserTestMustRegister()
        {
            RegisterRequest request = new RegisterRequest()
            {
                Name     = "test user",
                Email    = "*****@*****.**",
                Password = "******",
            };
            var result = await _authenticator.RegisterUser(request);

            Assert.Equal(StatusCode.Ok, result.StatusCode);
            Assert.NotNull(result.Token);
        }
Esempio n. 2
0
        public async Task <ActionResult <string> > Registration([FromBody] RegisterRequest formData)
        {
            var result = await _userManager.RegisterUser(formData);

            var response = result.StatusCode;

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

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

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

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

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