コード例 #1
0
        public void LogInWithWrongPassword()
        {
            LogInUserModel user = AccessExcelData.GetTestData <LogInUserModel>("LogInPageData.xlsx", "LogInUserData", "LogInWithWrongPass");

            logInPage.FillLogInData(user);
            logInPage.AssertMessageInvalidPass("Invalid login attempt.");
        }
コード例 #2
0
        public void LogInWithoutPass()
        {
            LogInUserModel user = AccessExcelData.GetTestData <LogInUserModel>("LogInPageData.xlsx", "LogInUserData", "LogInWithoutPass");

            logInPage.FillLogInData(user);
            logInPage.AssertMessageWithoutPass("The Password field is required.");
        }
コード例 #3
0
        public ActionResult LoginUser(LogInUserModel login)
        {
            if (login.UserName == null || login.Password == null)
            {
                ViewBag.Message = "You need to have a valid username and password";
                return(View("Error"));
            }
            else
            {
                var token = GetToken(login.UserName, login.Password);
                if (string.IsNullOrEmpty(token))
                {
                    return(View("Error"));
                }

                Session["tokenkey"] = token;

                using (HttpClient httpClient = new HttpClient())
                {
                    httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Session["tokenkey"].ToString());

                    var response = httpClient.GetAsync(new Uri(_endpoints.LogInUser)).Result;
                    var message  = response.Content.ReadAsStringAsync().Result;

                    if (response.IsSuccessStatusCode)
                    {
                        return(View("Index"));
                    }
                }
                return(View("Error"));
            }
        }
コード例 #4
0
        public void LogInWithWrongEmail()
        {
            LogInUserModel user = AccessExcelData.GetTestData <LogInUserModel>("LogInPageData.xlsx", "LogInUserData", "LogInWithWrongEmail");

            logInPage.FillLogInData(user);
            logInPage.AssertMessageInvalidEmail("The Email field is not a valid e-mail address.");
        }
コード例 #5
0
        public void LoginSuccessfully()
        {
            LogInUserModel user = AccessExcelData.GetTestData <LogInUserModel>("LogInPageData.xlsx", "LogInUserData", "LogInSuccessfully");

            logInPage.FillLogInData(user);
            logInPage.AssertLogInSuccessfully("Log off");
            logInPage.LogOffBtn.Click();
        }
コード例 #6
0
 public ActionResult LogIn(LogInUserModel model)
 {
     return(ValidatedCommandResult(model,
                                   new LogInUserCommand(model.Email, model.Password),
                                   () => {
         _authenticationService.SignIn(model.Email);
         return RedirectToAction("Index");
     }));
 }
コード例 #7
0
        public void LogInRemeberMe()
        {
            LogInUserModel user = AccessExcelData.GetTestData <LogInUserModel>("LogInPageData.xlsx", "LogInUserData", "LogInWithCheckBox");

            logInPage.FillLogInData(user);
            logInPage.AssertLogInSuccessfully("Log off");
            logInPage.Driver.Navigate().GoToUrl("https://google.com");
            logInPage.Driver.Navigate().GoToUrl("http://localhost:60634/Article/List");
            logInPage.AssertLogInSuccessfully("Log off");
        }
コード例 #8
0
ファイル: AuthController.cs プロジェクト: t-rolfin/EasyEats
        public async Task <IActionResult> CreateToken([FromBody] LogInUserModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.Values));
            }

            var result = await mediator.Send(model);

            return(Ok(result));
        }
コード例 #9
0
ファイル: LoginPage.cs プロジェクト: rozalya/QA-Automation
 public void FillLogInData(LogInUserModel userData)
 {
     if (userData.Email != null)
     {
         this.LogInEmail.SendKeys(userData.Email);
     }
     if (userData.Password != null)
     {
         this.LogInPassword.SendKeys(userData.Password);
     }
     if (userData.RememberMe == "1")
     {
         this.RememberMeCheckBox.Click();
     }
     this.LogInBtn.Click();
 }
コード例 #10
0
        public async Task <TokenModel> LogIn(LogInUserModel loginUserModel)
        {
            var email = await userManager.FindByEmailAsync(loginUserModel.Username);

            if (email == null)
            {
                var user = await userManager.FindByNameAsync(loginUserModel.Username);

                if (user != null)
                {
                    var result = await signInManager.CheckPasswordSignInAsync(user, loginUserModel.Password, false);

                    if (result.Succeeded)
                    {
                        //Create token
                        var token = await tokenManager.CreateToken(user); //new manager responsible with creating the token

                        return(new TokenModel {
                            Token = token
                        });
                    }
                }
            }
            else
            {
                var result = await signInManager.CheckPasswordSignInAsync(email, loginUserModel.Password, false);

                if (result.Succeeded)
                {
                    //Create token
                    var token = await tokenManager.CreateToken(email); //new manager responsible with creating the token

                    return(new TokenModel {
                        Token = token
                    });
                }
            }



            return(null);
        }
コード例 #11
0
        public async Task <IActionResult> Login([FromBody] LogInUserModel model)
        {
            try
            {
                var tokens = await authenticationManager.LogIn(model);

                if (tokens != null)
                {
                    return(Ok(tokens));
                }
                else
                {
                    return(BadRequest("Something failed"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest("Exception caught"));
            }
        }
コード例 #12
0
        public ActionResult LogIn(LogInUserModel user)
        {
            if (ModelState.IsValid)
            {
                if (IsValid(user.login, user.password))
                {
                    string userData;

                    if (dbUser.getUserByLogin(user.login).admin == true)
                    {
                        userData = "Admin";
                    }
                    else
                    {
                        userData = "User";
                    }

                    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                                                                                     user.login,
                                                                                     DateTime.Now,
                                                                                     DateTime.Now.AddDays(1),
                                                                                     false,
                                                                                     userData,
                                                                                     FormsAuthentication.FormsCookiePath);

                    string encTicket = FormsAuthentication.Encrypt(ticket);
                    Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("", "Login and password doesn't match");
                }
            }

            return(View(user));
        }