Esempio n. 1
0
        public ActionResult UserAuthentication(LoginModel objLogin)
        {
            try
            {
                CustomerLoginDetail userDetails = new CustomerLoginDetail();
                userDetails = LR.AuthenticateUser(objLogin);

                if (userDetails != null)
                {
                    if (userDetails.LoginId != null && (userDetails.LoginType == "5" || userDetails.LoginType == "8" || userDetails.LoginType == "1") && userDetails.LoginId != "123")
                    {
                        Session["UserSession"] = userDetails;

                        return(RedirectToAction("Index", "Lead"));
                    }
                    else
                    {
                        TempData["InvalidUserMessage"] = "User Does not Exist";
                    }
                }
                else
                {
                    TempData["InvalidUserMessage"] = "User Does not Exist";
                }
            }
            catch (Exception ex)
            {
                newexception.AddException(ex, "");
                TempData["InvalidUserMessage"] = ex.Message;
                return(RedirectToAction("Index"));
            }
            return(View("Index"));
        }
 public ActionResult UserAuthentication(LoginModel objLogin)
 {
     try
     {
         CustomerLoginDetail userDetails = new CustomerLoginDetail();
         //var status = DR.VerifyOTP(emailId, Convert.ToInt32(OTP));
         if (objLogin.OTP == null)
         {
             userDetails = LR.AuthenticateUser(objLogin);
         }
         else
         {
             var status = DR.VerifyOTP(objLogin.LoginId, Convert.ToInt32(objLogin.OTP));
             if (status)
             {
                 userDetails = LR.GetUserDetailsByLoginID(objLogin.LoginId);
             }
             else
             {
                 TempData["InvalidUserMessage"] = "There is problem in verifying OTP. Please check once";
             }
         }
         if (userDetails != null)
         {
             if (userDetails.LoginId != null)
             {
                 Session["UserSession"] = userDetails;
                 if (!string.IsNullOrEmpty(userDetails.GroupId))
                 {
                     return(RedirectToAction("Index", "Home"));
                 }
                 else// if (string.IsNullOrEmpty(objLogin.OTP))
                 {
                     return(RedirectToAction("Index", "CustomerManagement"));
                 }
             }
             else
             {
                 if (!string.IsNullOrEmpty(Convert.ToString(TempData["InvalidUserMessage"])))
                 {
                     TempData["InvalidUserMessage"] = "User Does not Exist";
                 }
             }
         }
         else
         {
             if (!string.IsNullOrEmpty(Convert.ToString(TempData["InvalidUserMessage"])))
             {
                 TempData["InvalidUserMessage"] = "User Does not Exist";
             }
         }
     }
     catch (Exception ex)
     {
         newexception.AddException(ex, "");
         TempData["InvalidUserMessage"] = ex.Message;
         return(RedirectToAction("Index"));
     }
     return(View("Index"));
 }
        public LoginUserDTO AuthenticateUser(LoginUserDTO user)
        {
            LoginRepository loginRepository   = new LoginRepository();
            LoginUserDTO    authenticatedUser = new LoginUserDTO();
            HashEngine      createHash        = new HashEngine();

            user.Password     = createHash.GeneratePasswordHash(user.Password);
            authenticatedUser = loginRepository.AuthenticateUser(user);
            return(authenticatedUser);
        }
Esempio n. 4
0
        public IActionResult Login([FromBody] LoginViewModel login)
        {
            IActionResult response = Unauthorized();
            var           user     = _repositorio.AuthenticateUser(login);

            if (user != null)
            {
                var TokenString = GenerateJSONWebToken(user);
                response = Ok(new { token = TokenString });
            }
            return(response);
        }