Ejemplo n.º 1
0
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            base.OnActionExecuted(context);
            //Get changeset model here
            Dmd_BusinessChangeSetDetails dmdBusinessChangeSetDetails = businessService.ToGetLatestChangeSetDetails(CurrentUserName);

            ViewBag.ChangesetBarModel = dmdBusinessChangeSetDetails;
        }
Ejemplo n.º 2
0
        public Dmd_BusinessChangeSetDetails ToGetLatestChangeSetDetails(string userName)
        {
            Dmd_BusinessChangeSetDetails dmBusinessChangeSetDetails = new Dmd_BusinessChangeSetDetails();

            try
            {
                //TODO:Riyaz
                HttpClient client = pharmixWebApiClient.InitializeClient(_apiBaseURI);

                HttpResponseMessage response = client.GetAsync("api/PharmixApi/ToGetLatestChangeSetDetails?userName=" + userName).Result;

                //Checking the response is successful or not which is sent using HttpClient
                if (response.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var result = response.Content.ReadAsStringAsync().Result;
                    dmBusinessChangeSetDetails = JsonConvert.DeserializeObject <Dmd_BusinessChangeSetDetails>(result);
                }
            }
            catch { }
            return(dmBusinessChangeSetDetails);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Login(LoginViewModel model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            if (ModelState.IsValid)
            {
                // This doesn't count login failures towards account lockout
                // To enable password failures to trigger account lockout, set lockoutOnFailure: true



                if (model.Email.ToLower().Equals(PharmixStaticHelper.SuperAdminUsername) && _customerService.ValidateSuperAdminPassword(model.Password))
                {                           //Pharmix user.
                    var user = new ApplicationUser
                    {
                        UserName      = PharmixStaticHelper.SuperAdminUsername,
                        Email         = model.Email,
                        SecurityStamp = DateTime.Now.ToString()
                    };
                    await _signInManager.SignInAsync(user, true);

                    Dmd_BusinessChangeSetDetails dmdBusinessChangeSetDetails = businessService.ToGetLatestChangeSetDetails(PharmixStaticHelper.SuperAdminUsername);
                    ViewBag.ChangesetBarModel = dmdBusinessChangeSetDetails;
                    return(RedirectToAction("Index", "Changeset"));
                }

                else
                {
                    var user = await _userManager.FindByNameAsync(model.Email);

                    if (user != null && (await _userManager.CheckPasswordAsync(user, model.Password)) && (user.IsResetPasswordRequired ?? false))
                    {           //Password reset required
                        return(RedirectToAction("ChangePassword", new { userName = model.Email }));
                    }
                    else
                    {
                        var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure : false);

                        if (result.Succeeded)
                        {
                            _logger.LogInformation("User logged in.");
                            Dmd_BusinessChangeSetDetails dmdBusinessChangeSetDetails = businessService.ToGetLatestChangeSetDetails(user.ToString());
                            ViewBag.ChangesetBarModel = dmdBusinessChangeSetDetails;
                            return(RedirectToAction("Index", "Changeset"));
                        }
                        else if (result.RequiresTwoFactor)
                        {
                            return(RedirectToAction(nameof(LoginWith2fa), new { returnUrl, model.RememberMe }));
                        }
                        if (result.IsLockedOut)
                        {
                            _logger.LogWarning("User account locked out.");
                            return(RedirectToAction(nameof(Lockout)));
                        }
                        else
                        {
                            ModelState.AddModelError(string.Empty, "Invalid login attempt.");
                            return(View(model));
                        }
                    }
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }