Ejemplo n.º 1
0
        public ActionResult Index(VMUserLogin user)
        {
            if (ModelState.IsValid)
            {
                var getUser = userDAL.Get(x => x.Email == user.EMail && x.Password == user.Password && x.IsActive == true);

                if (getUser == null)
                {
                    ViewBag.Error = "Email yada Şifre Hatalı";
                    return(View());
                }
                else
                {
                    if (getUser.UserType.UserTypeName == "admin")
                    {
                        Session["admin"] = getUser;
                    }
                    Session["user"] = getUser;

                    CartToDatabase();

                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Authenticate(VMUserLogin userLogin)
        {
            byte[] Key    = Convert.FromBase64String(_configuration.GetSection("Encryption").GetSection("Key").Value);
            byte[] IV     = Convert.FromBase64String(_configuration.GetSection("Encryption").GetSection("IV").Value);
            var    result = await Task.FromResult(_service.Authenticate(userLogin, Key, IV));

            return(Ok(result));
        }
Ejemplo n.º 3
0
        public VMUserLoginRespose Authenticate(VMUserLogin userLogin, byte[] Key, byte[] IV)
        {
            userLogin.Password = Convert.ToBase64String(_coreRepository.EncryptString(userLogin.Password, Key, IV));
            UserMaster         user         = _repository.Authenticate(userLogin);
            var                token        = _coreRepository.TokenGenerator(user);
            VMUserLoginRespose loginRespose = new VMUserLoginRespose();

            loginRespose.Token    = token;
            loginRespose.RoleID   = user.Role;
            loginRespose.UserName = user.UserName;
            return(loginRespose);
        }
Ejemplo n.º 4
0
 public ActionResult UserLogin(VMUserLogin userData)
 {
     if (ModelState.IsValid)
     {
         string localPassword = helper.HashValue(userData.PasswordValue);
         var    data          = dbReference.Users.FirstOrDefault(m => m.Email == userData.EmailId && m.Password.Equals(localPassword));
         if (data != null)
         {
             FormsAuthentication.SetAuthCookie(userData.EmailId, false);
             return(Json(new { success = true, }, JsonRequestBehavior.AllowGet));
         }
         return(Json(new { success = false, }, JsonRequestBehavior.AllowGet));
     }
     return(View());
 }