示例#1
0
        public ActionResult Index(UserLogInViewModel model)
        {
            GameRequestViewModel game = new GameRequestViewModel();

            game.UserName     = model.Name;
            game.UserPassword = model.Password;
            return(View(game));
        }
 public ActionResult LogIn(UserLogInViewModel model)
 {
     if (ModelState.IsValid && PlayerRepository.AuthorizationCheck(model.Name, model.Password) != null)
     {
         return(RedirectToAction("LogInSuccess", model));
     }
     else
     {
         ViewBag.Error = "Wrong name or password!";
         return(View());
     }
 }
示例#3
0
        public ActionResult UserLogIn()
        {
            UserLogInViewModel model = new UserLogInViewModel
            {
                //Email = Convert.ToString(Session["Email"])
            };

            //for to check whether stored in cookies or not

            if (Request.Cookies["userInfo"] != null)
            {
                model.Email    = Request.Cookies["userInfo"]["userEmail"];
                model.Password = Request.Cookies["userInfo"]["userPassword"];
            }
            return(View(model));
        }
示例#4
0
        public IActionResult Login(UserLogInViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(this.View());
            }

            var user = this.userService.GetUserOrNull(model.Username, model.Password);

            if (user == null)
            {
                return(this.View());
            }

            this.SignIn(user.Id, user.Username, user.Email);

            return(this.Redirect("/Trips/All"));
        }
示例#5
0
        public ActionResult LogIn(UserLogInViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            User user = service.LogIn(model.Email, model.Password);

            if (user == null)
            {
                var errMsg = "Email eller password er ikke korrekt";
                ModelState.AddModelError("", errMsg);
                return(View(model));
            }

            Session["LoggedIn"] = true;
            Session["User"]     = user;
            return(RedirectToAction("SignedUpEvents", "MainPage"));
        }
示例#6
0
        public async Task <IActionResult> Login(UserLogInViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (CheckUserLogin(model))
                {
                    List <Claim> claims = new List <Claim>
                    {
                        new Claim(ClaimTypes.NameIdentifier, model.UserName)
                    };
                    ClaimsIdentity  identity  = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
                    ClaimsPrincipal principal = new ClaimsPrincipal(identity);
                    await HttpContext.SignInAsync(principal);

                    return(RedirectToAction("Index", "Panel"));
                }
                else
                {
                    ModelState.AddModelError("", "Kullanıcı adı veya şifre hatalı");
                }
            }
            return(View());
        }
        public async Task <IActionResult> LogIn(UserLogInViewModel model, string ReturnUrl)
        {
            if (ModelState.IsValid)
            {
                var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password,
                                                                      model.RememberMe, false);

                if (result.Succeeded)
                {
                    if (!string.IsNullOrEmpty(ReturnUrl) && Url.IsLocalUrl(ReturnUrl))
                    {
                        return(Redirect(ReturnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }

                ModelState.AddModelError(string.Empty, "Invalid Login Attempt");
            }

            return(View(model));
        }
示例#8
0
        public ActionResult UserLogIn(UserLogInViewModel userLogInViewModel)
        {
            try
            {
                //password Hashing passwords with MD5 or sha-256 C#
                var TempPassword = Convert.ToBase64String(System.Security.Cryptography.SHA256.Create()
                                                          .ComputeHash(Encoding.UTF8.GetBytes(userLogInViewModel.Password)));

                var obj = db.UserRegistrations.Where(s => s.Email == userLogInViewModel.Email && s.Password == TempPassword).FirstOrDefault();

                if (obj != null)
                {
                    if (obj.IsActive)
                    {
                        //var result=(from item in db.UserRegistrations
                        //             join ct in db.UserInRoles on item.UserId equals ct.UserId
                        //             join cy in db.Roles on ct.RoleId equals cy.RoleId
                        //             where item.Email.Equals(obj.Email)
                        //               select new UserRegistrationViewModel
                        //               {
                        //                   UserId = item.UserId,
                        //                   Email = item.Email,
                        //                   RoleName = cy.RoleName
                        //               }).ToList();

                        // UserInRole userInRole = new UserInRole();
                        Session["EmailInfo"] = userLogInViewModel.Email;
                        Session["UserId"]    = obj.UserId;
                        Session["RoleId"]    = db.UserInRoles.Where(m => m.UserId == obj.UserId).Select(x => x.RoleId).FirstOrDefault();;
                        if (userLogInViewModel.RememberMe)
                        {
                            Response.Cookies["userInfo"]["userEmail"]    = userLogInViewModel.Email;
                            Response.Cookies["userInfo"]["userPassword"] = userLogInViewModel.Password;
                            Response.Cookies["userInfo"]["lastVisit"]    = DateTime.Now.ToString();
                            // Response.Cookies["userInfo"].Expires = DateTime.Now.AddDays(1);
                            Response.Cookies["domain"].Domain = "http://localhost/StudentProject/";
                        }
                        if (Session["EmailInfo"] != null)
                        {
                            // return RedirectToAction("Index", "Default");

                            return(View("~/Views/UserLogIn/UserDashBoard.cshtml"));
                        }
                        else
                        {
                            return(RedirectToAction("UserLogIn"));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("DeActivatedPage"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Email or Password is Worng. Please check. ");
                    // return RedirectToAction("UserLogIn");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception source: {0} sorry to show list", ex.Message);
            }
            return(View(userLogInViewModel));
        }
 public ActionResult LogInSuccess(UserLogInViewModel model)
 {
     return(RedirectToAction("Index", "Home", model));
 }
示例#10
0
 private bool CheckUserLogin(UserLogInViewModel model)
 {
     return(userService.CheckUserLogin(model.UserName, model.Password));
 }
示例#11
0
 public ActionResult Users(UserLogInViewModel model)
 {
     return(View(model));
 }