Exemple #1
0
        public ActionResult SignIn([Bind(Include = "Login, Password")] ExistingUser user)
        {
            _logger.Info($"POST Account/SignIn for {user}");

            if (!ModelState.IsValid)
            {
                return(View("SignIn", user));
            }

            var userStore    = new UserStore <IdentityUser>();
            var userManager  = new UserManager <IdentityUser>(userStore);
            var identityUser = userManager.Find(user.Login, user.Password);

            if (identityUser != null)
            {
                var authenticationManager = HttpContext.GetOwinContext().Authentication;
                var userIdentity          = userManager.CreateIdentity(identityUser, DefaultAuthenticationTypes.ApplicationCookie);

                authenticationManager.SignIn(new AuthenticationProperties()
                {
                    IsPersistent = false
                }, userIdentity);

                _logger.Info($"{user} is successfully authenticated!");

                return(RedirectToAction(controllerName: "Project", actionName: "List"));
            }
            else
            {
                _logger.Info($"{user} is not found!");

                ViewBag.ErrorMessage = CommonResource.WrongLoginOrPassword;
                return(View("SignIn"));
            }
        }
        //No Authorization Set intentionally
        public IActionResult getInExisting([FromBody] ExistingUser existingUser)
        {
            Hashing sai = new Hashing();

            existingUser.epd = sai.HashingPlain(existingUser.epd);
            string msg     = "Bad User Name or Password";
            string success = "n";
            var    hasUser = db.UserBasic.Where(x => x.Email == existingUser.eud);

            if (hasUser.Any())
            {
                UserBasic user = hasUser.FirstOrDefault();
                bool      map  = db.UserRoleMap.Any(x => x.UserIdSystem == user.UserIdSystem);
                if (user.PdSystem == existingUser.epd && map)
                {
                    AuthSession.SetUserId(HttpContext, user.UserIdSystem);
                    success = "y";
                    msg     = "Authorization Complete";
                }
            }

            var result = new { success = success, msg = msg };

            return(Json(result));
        }
        public IActionResult getInExisting([FromBody] ExistingUser existingUser)
        {
            SaiHashing sai = new SaiHashing();

            existingUser.epd = sai.Hashing(existingUser.epd);
            var result = new { success = true, user = existingUser };

            return(Json(result));
        }
Exemple #4
0
        public void ExistingUser()
        {
            ExistingUser Eu = new ExistingUser();

            Eu.ExistingUsers();
        }