Example #1
0
        public ActionResult ForgotPassword(UserLoginVM vm)
        {
            string emailid = vm.UserName;
            var    _user   = db.UserRegistrations.Where(cc => cc.UserName == emailid).FirstOrDefault();

            if (_user != null)
            {
                PickupRequestDAO _dao        = new PickupRequestDAO();
                string           newpassword = _dao.RandomPassword(6);

                _user.Password        = newpassword;
                db.Entry(_user).State = EntityState.Modified;
                db.SaveChanges();
                EmailDAO _emaildao = new EmailDAO();
                _emaildao.SendForgotMail(_user.UserName, "User", newpassword);
                TempData["SuccessMsg"] = "Reset Password Details are sent,Check Email!";

                return(RedirectToAction("Home", "Home"));
                //return Json(new { status = "ok", message = "Reset Password Details are sent,Check Email" }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                Session["ForgotStatus"]  = "Forgot";
                Session["StatusMessage"] = "Invalid EmailId!";
                return(RedirectToAction("Home", "Home"));
                //return Json(new { status = "Failed", message = "Invalid EmailId!" }, JsonRequestBehavior.AllowGet);
            }
        }
Example #2
0
        public IActionResult Login(UserLoginVM user)
        {
            var userRepos = _service.Login(user.Email.ToLower(), user.Password);

            if (userRepos == null)
            {
                return(Unauthorized());
            }

            var claims = new[]
            {
                new Claim(ClaimTypes.NameIdentifier, userRepos.UserId.ToString()),
                new Claim(ClaimTypes.Name, userRepos.Email)
            };

            var key = new SymmetricSecurityKey(Encoding.UTF8
                                               .GetBytes(_config.GetSection("AppSettings:Token").Value));
            var creds           = new SigningCredentials(key, SecurityAlgorithms.HmacSha512Signature);
            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject            = new ClaimsIdentity(claims),
                Expires            = DateTime.Now.AddHours(1),
                SigningCredentials = creds
            };
            var tokenHandler = new JwtSecurityTokenHandler();
            var token        = tokenHandler.CreateToken(tokenDescriptor);

            return(Ok(new
            {
                token = tokenHandler.WriteToken(token)
            }));
        }
        public ActionResult doLogin(UserLoginVM rec)
        {
            if (ModelState.IsValid)
            {
                UserTbl urec = entity.UserTbls.SingleOrDefault(p => p.EmailID == rec.EmailID && p.Password == rec.Password);
                if (urec != null)
                {
                    Session["UserID"]   = urec.UserID;
                    Session["UserName"] = urec.UserName;
                    if (Session["ProdID"] != null)
                    {
                        Int64 prod = Convert.ToInt64(Session["ProdID"]);
                        Session.Remove("ProdID");
                        return(RedirectToAction("AddToCart", "Cart", new { id = prod }));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }

                ModelState.AddModelError("", "Invalid Email ID or Password!");
                return(View(rec));
            }
            return(View(rec));
        }
Example #4
0
        public async Task <IActionResult> Login(UserLoginVM model, string returnUrl = null)
        {
            // 로그인 단계
            if (ModelState.IsValid)
            {
                if (_repository.IsCorrectUser(model))
                {
                    var principal = _repository.GetClaimsPrincipal(model);


                    await HttpContext.SignInAsync(principal);


                    if (string.IsNullOrWhiteSpace(returnUrl))
                    {
                        return(LocalRedirect("/"));
                    }
                    else
                    {
                        return(LocalRedirect(returnUrl));
                    }
                }

                return(View(model));
            }

            // 로그인 실패
            return(View(model));
        }
Example #5
0
        public ActionResult ChangePassword(UserLoginVM vm)
        {
            string emailid = vm.UserName;
            var    _user   = entity.UserRegistrations.Where(cc => cc.EmailId == emailid && cc.Password == vm.Password).FirstOrDefault();

            if (_user != null)
            {
                _user.Password            = vm.NewPassword;
                entity.Entry(_user).State = EntityState.Modified;
                entity.SaveChanges();
                EmailDAO _emaildao = new EmailDAO();
                _emaildao.SendForgotMail(_user.EmailId, "User", vm.NewPassword);
                TempData["SuccessMsg"] = "Password Changed Successfully!";
                return(RedirectToAction("Index", "Login"));
                //return Json(new { status = "ok", message = "Reset Password Details are sent,Check Email" }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                //TempData["ErrorMsg"] = "Invalid EmailId or Password!";
                Session["ResetStatus"]   = "Reset";
                Session["StatusMessage"] = "Invalid Credential!";
                return(RedirectToAction("Index", "Login"));
                //return Json(new { status = "Failed", message = "Invalid EmailId!" }, JsonRequestBehavior.AllowGet);
            }
        }
Example #6
0
        public ActionResult Login()
        {
            var compdetail = db.AcCompanies.FirstOrDefault();

            ViewBag.CompanyName = compdetail.AcCompany1;
            string userName = string.Empty;

            if (System.Web.HttpContext.Current != null &&
                System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {
                System.Web.Security.MembershipUser usr = Membership.GetUser();
                if (usr != null)
                {
                    userName = usr.UserName;
                }
            }

            UserLoginVM vm = new UserLoginVM();

            vm.UserName = userName;
            //ViewBag.Depot = db.tblDepots.ToList();
            //ViewBag.fyears = db.AcFinancialYearSelect().ToList();
            //TempData["SuccessMsg"] = "You have successfully Updated Customer.";
            //ViewBag.ErrorMessage = "not working";
            //var compdetail = db.AcCompanies.FirstOrDefault();
            //Session["CurrentCompanyID"] = compdetail.AcCompanyID;

            //Session["CompanyName"] = compdetail.AcCompany1;
            //ViewBag.CompanyName = compdetail.AcCompany1;
            return(View(vm));
        }
Example #7
0
        public TransactionResult <object> BL_ValidatePasswordAndDeleteUser(UserLoginVM p_UserLoginVM)
        {
            MST_UserInfo UserObj = new DAL_User().DAL_GetUserValidity(p_UserLoginVM.LoginEmail).Data;

            if (new MD5Hashing().GetMd5Hash(p_UserLoginVM.LoginPassword).Equals(UserObj.Password))
            {
                if (BL_DeleteUser(UserObj.UserId))
                {
                    return(new TransactionResult <object>
                    {
                        Success = true,
                        RedirectURL = "/Home/Index",
                        Message = "Account Deletion successful"
                    });
                }
                return(new TransactionResult <object>
                {
                    Success = false,
                    Message = "Something went wrong.Please try again"
                });
            }
            else
            {
                return(new TransactionResult <object>
                {
                    Success = false,
                    Message = "Incorrect password"
                });
            }
        }
Example #8
0
        public ActionResult Login(UserLoginVM model) //notice we’re using the ViewModel
        {
            if (ModelState.IsValid)
            {
                //var hashedPassword = Crypto.HashPassword(model.Password);
                var hashed = HashClass.Encode(model.Password);
                var db     = new MyDBEntities();
                var v      = db.users.Where(u => u.Username.Equals(model.Username) && u.Password.Equals(hashed)).FirstOrDefault();

                if (v != null)
                {
                    ViewData["Message"] = "Login Successful";
                    Session["loggedIn"] = true;
                    Session["user"]     = v.Username;
                    Session["id"]       = v.Id;
                    Session["isAdmin"]  = v.isAdmin;
                    if ((int)Session["isAdmin"] == 1)
                    {
                        return(RedirectToAction("DisplayCars", "Car"));
                    }
                    else
                    {
                        return(RedirectToAction("UserArea", "Car"));
                    }
                }
                else
                {
                    ViewData["Message"] = "Login Unsuccessful";
                }
            }
            return(View(model));
        }
Example #9
0
        public ActionResult Login(UserLoginVM userVM)
        {
            Debug.WriteLine("Login called");
            if (userVM.Email == null || userVM.Password == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var user     = _userService.GetUserByEmail(userVM.Email);
            var password = userVM.Password;

            if (user != null)
            {
                if (user.Password == password && user.Role == "ADMIN")
                {
                    Session["token"]   = "admin_token";
                    Session["user_id"] = user.Id;
                    Debug.WriteLine(Session["token"]);
                    return(RedirectToAction("Index", "User"));
                }
                else if (user.Password == password && user.Role == "USER")
                {
                    Session["token"]   = "user_token";
                    Session["user_id"] = user.Id;
                    return(RedirectToAction("Index", "Post"));
                }
                else
                {
                    TempData["message"] = "Invalid credentials";
                    return(View());
                }
            }
            TempData["message"] = "Invalid credentials";
            return(View());
        }
Example #10
0
        public async Task <IActionResult> Token([FromBody] LoginIM model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var user = await _context.Users.FirstOrDefaultAsync(d => d.Username == model.Username);

            var salt    = Convert.FromBase64String(user.SecurityStamp);
            var pwdHash = EncryptionHelper.HashPasswordWithSalt(model.Password, salt);

            if (user.PasswordHash != pwdHash)
            {
                return(BadRequest(new ReturnVM {
                    Message = "用户名或密码不正确。"
                }));
            }

            var token = await GetJwtSecurityTokenAsync(user);

            var vm = new UserLoginVM
            {
                Id       = user.Id,
                Username = user.Username,
                RealName = user.RealName,
                Email    = user.Email,
                PhotoUrl = user.PhotoUrl,
                Token    = new JwtSecurityTokenHandler().WriteToken(token)
            };

            return(Ok(vm));
        }
Example #11
0
 public HttpResponseMessage SignIn(UserLoginVM _userLogin)
 {
     try
     {
         _userLogin.Password = Common.EncryptedPassword(_userLogin.Password);
         UserLoginVM _UserLoginVM = _userBLL.SignIn(_userLogin);
         if (_UserLoginVM == null)
         {
             String _FailureCode = String.Empty;
             _Message        = "\"message\":\"Invalid UserName/Email Address.\",";
             _strJSONContent = Common.FailureResponseRequest(_FailureCode, _Message);
         }
         else if (_UserLoginVM != null && _UserLoginVM.Password == "InvalidPassword")
         {
             String _FailureCode = String.Empty;
             _Message        = "\"message\":\"Invalid Password.\",";
             _strJSONContent = Common.FailureResponseRequest(_FailureCode, _Message);
         }
         else
         {
             String _SuccessCode = "104";
             _Message = "\"message\":\"Successfully Logged In.\",";
             JSONSuccessResult(_UserLoginVM, _SuccessCode, _UserLoginVM.HeaderToken);
         }
     }
     catch (Exception ex)
     {
         _Message = ex.Message;
         _strJSONContent.Append("{\"status\":\"Failed\"}");
     }
     return(Common.ResponseOutput(_strJSONContent));
 }
        public AppUserAuth ValidateUser(UserLoginVM user)
        {
            AppUserAuth   ret      = new AppUserAuth();
            LoginActivity authUser = null;
            var           result   = false;

            // Attempt to validate user
            authUser = (from u in context.LoginActivity
                        where u.UserName.ToLower() == user.userName.ToLower()
                        select(u)).FirstOrDefault();

            if (authUser == null)
            {
                throw new Exception("User not registered!");
            }

            result = VerifyPasswordHash(user.password, authUser.PasswordHash, authUser.PasswordSalt);

            if (result == false)
            {
                throw new Exception("Username or password incorrect not registered!");
            }

            ret.BearerToken = CreateToken(authUser.UserName);

            return(ret);
        }
Example #13
0
        public ActionResult Login(UserLoginVM model)
        {
            //Проверяем модель на валидность
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            //Проверяем пользователя на валидность
            bool isValid = false;

            using (Db db = new Db())
            {
                if (db.Users.Any(x => x.UserName.Equals(model.Username) && x.Password.Equals(model.Password)))
                {
                    isValid = true;
                }
                if (!isValid)
                {
                    ModelState.AddModelError("", "Invalid username of password.");
                    return(View(model));
                }
                else
                {
                    FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe);
                    return(Redirect(FormsAuthentication.GetRedirectUrl(model.Username, model.RememberMe)));
                }
            }
        }
        public ActionResult LoginUser(UserLoginVM pLogin)
        {
            string  jsonResult = _objRepository.LoginUser(pLogin);
            dynamic data       = JObject.Parse(jsonResult);

            if (data.success == "True")
            {
                _uow.AutitTrails.Add(new AuditTrial()
                {
                    UserId         = SessionManager.CurrentUser.UserId,
                    EventTypeId    = 8,
                    EventTime      = DateTime.Now,
                    EventDetails   = "User Machine IP is " + Request.UserHostAddress,
                    EventDetailsAr = "رقم جهاز المستخدم هو  " + Request.UserHostAddress
                });
                _uow.Save();
                return(Json(jsonResult));
            }
            _uow.AutitTrails.Add(new AuditTrial()
            {
                EventTypeId    = 8,
                EventTime      = DateTime.Now,
                EventDetails   = "this Machine IP is " + Request.UserHostAddress + " " + "tried to log in with invalid username or password",
                EventDetailsAr = "جهاز هذا المستخدم   " + Request.UserHostAddress + " " + "حاول الدخول علي البرنامج باسم مستخدم او كلمة مرور خاطئة"
            });
            _uow.Save();
            return(Json(jsonResult));
        }
Example #15
0
        public HttpResponseMessage SignUp(UserLoginVM _userLogin)
        {
            UserLoginVM _UserVM = _userBLL.SignUp(_userLogin);

            if (_UserVM != null && _UserVM.UserName == "UserInvalid")
            {
                String _FailureCode = "";
                String _Message     = "\"message\":\"Username already exists.\",";
                _success        = false;
                _strJSONContent = User_BLL.FailureResponseRequest(_FailureCode, _Message);
            }
            else if (_UserVM != null && _UserVM.Email == "EmailInvalid")
            {
                String _FailureCode = "";
                String _Message     = "\"message\":\"Email Address already exists.\",";
                _success        = false;
                _strJSONContent = User_BLL.FailureResponseRequest(_FailureCode, _Message);
            }
            else
            {
                String _JSONData    = new JavaScriptSerializer().Serialize(_UserVM);
                String _SuccessCode = "103";
                String _Message     = "\"message\":\"Successfully Registered.\",";
                _strJSONContent = User_BLL.GenerateReturnJSONData(_UserVM.HeaderToken, _JSONData, _SuccessCode, _Message);
            }
            return(ResponseOutput());
        }
Example #16
0
        public TransactionResult <MST_UserInfo> BL_GetUserValidity(UserLoginVM p_UserLoginVM)
        {
            MST_UserInfo UserObj = new DAL_User().DAL_GetUserValidity(p_UserLoginVM.LoginEmail).Data;

            if (UserObj != null)
            {
                if (new MD5Hashing().GetMd5Hash(p_UserLoginVM.LoginPassword).Equals(UserObj.Password) && UserObj.IsAdmin == true)
                {
                    UserObj.UserStatus = MST_UserInfo.EnumUserStatus.AuthenticatedAdmin;
                }
                else if (new MD5Hashing().GetMd5Hash(p_UserLoginVM.LoginPassword).Equals(UserObj.Password) && UserObj.IsAdmin == false)
                {
                    UserObj.UserStatus = MST_UserInfo.EnumUserStatus.AuthenticatedUser;
                }
                else
                {
                    UserObj.UserStatus = MST_UserInfo.EnumUserStatus.NonAuthenticatedUser;
                }
                return(new TransactionResult <MST_UserInfo>
                {
                    Success = true,
                    Data = UserObj
                });
            }
            else
            {
                return(new TransactionResult <MST_UserInfo>
                {
                    Success = false,
                    Message = "Incorrect Email"
                });
            }
        }
Example #17
0
        public async Task <AuthentificationResult> SignIn(UserLoginVM model)
        {
            var account = await _accountRepository.FindByNameAccount(model.Email);

            if (account == null)
            {
                return(new AuthentificationResult
                {
                    Errors = new[] { "User does not exist!" }
                });
            }

            var passwordValid = await _accountRepository.CheckPassword(account, model.Password);

            if (!passwordValid)
            {
                return(new AuthentificationResult
                {
                    Errors = new[] { "User/password combination are wrong!" }
                });
            }

            await _accountRepository.SignIn(model.Email, model.Password, model.RememberMe, false);

            return(new AuthentificationResult
            {
                Success = true
            });
        }
Example #18
0
        public HttpResponseMessage SignIn(UserLoginVM _userLogin)
        {
            UserLoginVM _UserLoginVM = _userBLL.SignIn(_userLogin);

            if (_UserLoginVM == null)
            {
                String _FailureCode = "";
                String _Message     = "\"message\":\"Invalid UserName/Email Address.\",";
                _success        = false;
                _strJSONContent = User_BLL.FailureResponseRequest(_FailureCode, _Message);
            }
            else if (_UserLoginVM != null && _UserLoginVM.Password == "InvalidPassword")
            {
                String _FailureCode = "";
                String _Message     = "\"message\":\"Invalid Password.\",";
                _success        = false;
                _strJSONContent = User_BLL.FailureResponseRequest(_FailureCode, _Message);
            }
            else
            {
                String _JSONData    = new JavaScriptSerializer().Serialize(_UserLoginVM);
                String _SuccessCode = "104";
                String _Message     = "\"message\":\"Successfully Logged In.\",";
                _strJSONContent = User_BLL.GenerateReturnJSONData(_UserLoginVM.HeaderToken, _JSONData, _SuccessCode, _Message);
            }
            return(ResponseOutput());
        }
Example #19
0
        /// <summary>
        /// Login User  -- 2 Database calls
        /// </summary>
        /// <param name="_userLoginVM"></param>
        /// <returns></returns>
        public UserLoginVM SignIn(UserLoginVM _userLoginVM)
        {
            User _user = new User {
                UserName = _userLoginVM.UserName, Email = _userLoginVM.Email, Password = _userLoginVM.Password
            };

            _user = _objUserDAL.CheckUserExists(_user);    // Sign In -- 1st Hit to Database

            if (_user != null)
            {
                if (_user.Password == _userLoginVM.Password)
                {
                    return(UserSignIn(_userLoginVM, _user));
                }
                else
                {
                    _userLoginVM.Password = "******";
                    return(_userLoginVM);
                }
            }
            else
            {
                return(null);
            }
        }
Example #20
0
        private UserLoginVM MakeUserVM(User item)
        {
            _objUserLoginVM = new UserLoginVM()
            {
                UserID          = item.UserID,
                UserName        = item.UserName,
                Email           = item.Email,
                Password        = item.Password,
                FirstName       = item.FirstName,
                LastName        = item.LastName,
                UserType        = item.UserType,
                HeaderToken     = item.HeaderToken,
                IPAddress       = item.IPAddress,
                IsActive        = item.IsActive,
                ProfileImageUrl = item.ProfileImageUrl,
                SocialID        = item.SocialID,
                IsSocialUser    = item.IsSocialUser
            };

            if (item.UserLogins != null && item.UserLogins.Count > 0)
            {
                var lastItem = item.UserLogins.LastOrDefault();

                _objUserLoginVM.DeviceToken = lastItem.DeviceToken;
                _objUserLoginVM.DeviceType  = lastItem.DeviceType;
            }

            return(_objUserLoginVM);
        }
Example #21
0
 public ActionResult SignIn(UserLoginVM obj)
 {
     if (ModelState.IsValid)
     {
         var res = (from s in db.Users
                    where s.UserName == obj.UserName &&
                    s.UserPassword == obj.UserPassword
                    select s).SingleOrDefault();
         var    t     = res.RoleID;
         String uname = res.UserName;
         Session["Name"] = uname;
         if (res != null)
         {
             if (t == 0)
             {
                 return(RedirectToAction("Index", "Home"));
             }
             else
             {
                 return(RedirectToAction("RegisterCustomer", "Register"));
             }
         }
         else
         {
             ModelState.AddModelError("", "Invalid Password...Pls re-type");
             return(View());
         }
     }
     else
     {
         ModelState.AddModelError("", "Invalid Email ID");
     }
     return(View());
 }
Example #22
0
        public async Task <IActionResult> Login([FromBody] UserLoginVM model)
        {
            if (!ModelState.IsValid)
            {
                var errors = CustomValidator.GetErrorsByModel(ModelState);
                return(BadRequest(errors));
            }
            var result = await _signInManager
                         .PasswordSignInAsync(model.Name, model.Password,
                                              false, false);

            if (!result.Succeeded)
            {
                return(BadRequest(new { Password = "******" }));
            }

            var user = await _userManager.FindByNameAsync(model.Name);

            await _signInManager.SignInAsync(user, isPersistent : false);

            return(Ok(
                       new
            {
                token = CreateTokenJwt(user)
            }));
        }
Example #23
0
 public HttpResponseMessage SignUp(UserLoginVM _userLogin)
 {
     try
     {
         _userLogin.Password = Common.EncryptedPassword(_userLogin.Password);
         UserLoginVM _UserLoginVM = _userBLL.SignUp(_userLogin);
         if (_UserLoginVM != null && _UserLoginVM.UserName == "UserInvalid")
         {
             String _FailureCode = String.Empty;
             _Message        = "\"message\":\"Username already exists.\",";
             _strJSONContent = Common.FailureResponseRequest(_FailureCode, _Message);
         }
         else if (_UserLoginVM != null && _UserLoginVM.Email == "EmailInvalid")
         {
             String _FailureCode = String.Empty;
             _Message        = "\"message\":\"Email Address already exists.\",";
             _strJSONContent = Common.FailureResponseRequest(_FailureCode, _Message);
         }
         else
         {
             String _SuccessCode = "103";
             _Message = "\"message\":\"Successfully Registered.\",";
             JSONSuccessResult(_UserLoginVM, _SuccessCode, _UserLoginVM.HeaderToken);
         }
     }
     catch (Exception ex)
     {
         _Message = ex.Message;
         _strJSONContent.Append("{\"status\":\"Failed\"}");
     }
     return(Common.ResponseOutput(_strJSONContent));
 }
        public ActionResult Index()
        {
            var model = new UserLoginVM();

            model.Login    = new LoginVM();
            model.register = new UserVM();
            return(View(model));
        }
Example #25
0
        public async Task <IActionResult> Login(UserLoginVM model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            if (ModelState.IsValid)
            {
                var user = _accountBusiness.GetUser(model.Email, model.Password);
                #region  Login Süreci
                if (user != null)
                {
                    var claims = new List <Claim>
                    {
                        new Claim(ClaimTypes.Name, model.Email),
                        new Claim(ClaimTypes.Locality, user.Language)
                    };
                    var roles = user.UserRoles.Split(',').ToList();
                    foreach (var item in roles)
                    {
                        claims.Add(new Claim(ClaimTypes.Role, item));
                    }
                    var             userIdentity = new ClaimsIdentity(claims, "login");
                    ClaimsPrincipal principal    = new ClaimsPrincipal(userIdentity);
                    await HttpContext.SignInAsync(principal);

                    var serialised = JsonConvert.SerializeObject(user);
                    HttpContext.Session.SetString("SessionUser", serialised);
                    HttpContext.Session.SetString("ProjectCulture", user.Language);
                    return(RedirectToLocal(returnUrl));
                }
                else
                {
                    var mailuser = _accountBusiness.GetUserByEmail(model.Email);
                    if (mailuser != null)
                    {
                        Users selectedUser = _usersRepository.TableNoTracking.Where(i => i.Id == mailuser.Id).FirstOrDefault();
                        selectedUser.IncorrectLoginCount = mailuser.IncorrectLoginCount + 1;
                        _usersRepository.Update(selectedUser);
                        _uow.SaveChanges();
                        if (selectedUser.IncorrectLoginCount >= 5)
                        {
                            return(RedirectToAction("ForgotPassword", "Account"));
                        }
                    }
                    ModelState.AddModelError("Email", "Hatalı Email veya Şifre");
                    return(View(model));
                }

                #endregion
            }
            else if (model.Password == null)
            {
                var user = _accountBusiness.GetUserByEmail(model.Email);
                if (user != null && user.IsFirstLogin == true)
                {
                    return(RedirectToAction("ForgotPassword", "Account"));
                }
            }
            return(View(model));
        }
Example #26
0
 internal async Task <SignInResult> TryLoginAsync(UserLoginVM userLoginVM)
 {
     return(await signInManager.PasswordSignInAsync(
                userLoginVM.Username,
                userLoginVM.Password,
                isPersistent : false,
                lockoutOnFailure : false
                ));
 }
Example #27
0
        public async Task <ActionResult <UserDTO> > LoginAsync([FromBody] UserLoginVM userLoginVM)
        {
            var user = await userService.LogInAsync(userLoginVM.UserName, userLoginVM.Password, config["Jwt:Key"]);

            if (user == null)
            {
                return(Unauthorized());
            }
            return(user);
        }
        public async Task <IActionResult> GenerateTokens([FromBody] UserLoginVM userLoginModel)
        {
            var userDto = await Mapper.Map <UserLoginVM, UserDTO>(userLoginModel);

            if (await _userService.CheckPassword(userDto))
            {
                return(FormattedResponse(await _tokenService.GenerateTokens(userDto)));
            }

            return(Unauthorized());
        }
        public IActionResult Login(UserLoginVM viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            service.LoginSuccess(viewModel);

            return(RedirectToAction("Index", "Memory"));
            //TODO: redirect till en annan view som man får när man är inloggad, med fler features.
        }
Example #30
0
        public ActionResult Login(string userName, string pwd, string returnurl = "/")
        {
            UserLoginVM um = new UserLoginVM
            {
                UserId   = 1,
                UserName = userName
            };

            CustomerFormsAuthentication.SignIn(userName, 7 * 24 * 60, um);

            return(Redirect(returnurl));
        }