Exemple #1
0
        public async void GetUserData_FromInitializedDbTable_ExpectedEqualActual()
        {
            // arrange
            var expected = GetUserData();

            fixture.dbAuth.Add(expected);
            await fixture.dbAuth.SaveChangesAsync();

            // act
            var actual = await logic.GetUserData(expected.Login);

            // assert
            Assert.Equal(actual.Login, expected.Login);
            Assert.Equal(actual.RoleName, expected.RoleName);
        }
Exemple #2
0
        public async Task <IActionResult> Login(LoginModel loginModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(loginModel));
            }

            var statusMessage = await logicValidation.CheckLogin(loginModel);

            if (statusMessage.IsCompleted)
            {
                var userData = await logic.GetUserData(loginModel.Login);
                await Authenticate(userData.Login, userData.RoleName);

                await logProvider.AddToLogAsync("User logged in.", loginModel.Login);

                return(RedirectToRoute(HubRouting.Index));
            }
            else
            {
                return(View("CustomError", statusMessage));
            }
        }