public ActionResult Index()
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();
                // string LoginUserType = System.Web.HttpContext.Current.Session["LoginUserType"].ToString();
                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                if (authCookie != null)
                {
                    ticket = FormsAuthentication.Decrypt(authCookie.Value);

                    if (_UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim() == "administrator")
                    {
                        ViewBag.ProfilePicURL = _UserDetailsBusinessLogic.GetUserDetails(ticket.Name)
                                                .FirstOrDefault().ProfilePicURL;
                        ViewBag.Username         = ticket.Name;
                        ViewBag.UserType         = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim();
                        ViewBag.RedirectedUserId = "0";


                        return(View());
                    }
                    else
                    {
                        this.HttpContext.Session["ErrorMsg"] = "AccessDeniedError";
                        return(RedirectToAction("Index", "LoginError"));
                    }
                }
                else
                {
                    this.HttpContext.Session["ErrorMsg"] = "LoginErr";
                    return(RedirectToAction("Index", "Login"));
                }
            }
            catch (Exception ex)
            {
                currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex);

                this.HttpContext.Session["ErrorMsg"] = "PageLoadError";
                return(RedirectToAction("Index", "LoginError"));
            }
        }
Example #2
0
        private static int redirectedUserId = 0; //Variable to get when user Id is redirected from another page

        public ActionResult Index(string userId = null)
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                // string LoginUserType = System.Web.HttpContext.Current.Session["LoginUserType"].ToString();
                _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();
                _EncryptionModule         = new EncryptionModule();
                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];

                if (authCookie != null)
                {
                    ticket = FormsAuthentication.Decrypt(authCookie.Value);

                    ViewBag.Username         = ticket.Name;
                    ViewBag.UserType         = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim();
                    ViewBag.RedirectedUserId = userId != null?_EncryptionModule.Decrypt(userId.ToString()) : "0";

                    redirectedUserId = userId != null?Convert.ToInt32(_EncryptionModule.Decrypt(userId.ToString())) : 0;

                    //Initialize AWS Configurations => Required for image uploads
                    InitAWSS3Configurations();

                    return(View());
                }
                else
                {
                    this.HttpContext.Session["ErrorMsg"] = "LoginErr";
                    return(RedirectToAction("Index", "Login"));
                }
            }
            catch (Exception ex)
            {
                currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex);

                this.HttpContext.Session["ErrorMsg"] = "PageLoadError";
                return(RedirectToAction("Index", "LoginError"));
            }
        }
Example #3
0
        public ActionResult Index()
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                int userId = 0;
                _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();
                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];


                if (authCookie != null)
                {
                    ticket         = FormsAuthentication.Decrypt(authCookie.Value);
                    userId         = _UserDetailsBusinessLogic.GetUserID(ticket.Name);
                    loggedUserType = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim();
                }
                else
                {
                    loggedUserType = System.Web.HttpContext.Current.Session["LoginUserType"].ToString().ToLower().Trim();
                }

                //This will be used in the cshtml to check whether the user is actively logged in
                //and is of Administrator User Type
                ViewBag.UserId           = userId;
                ViewBag.UserType         = loggedUserType;
                ViewBag.RedirectedUserId = "0";

                return(View());
            }
            catch (Exception ex)
            {
                currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex);

                this.HttpContext.Session["ErrorMsg"] = "PageLoadError";
                return(RedirectToAction("Index", "LoginError"));
            }
        }
Example #4
0
        public JsonResult LoadUserGroups(int isActive)
        {
            //isActive=>Denotes which type of data to get(i.e,active,inactive or all)
            try
            {
                _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();
                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                string     userType   = "N/A";

                if (authCookie != null)
                {
                    FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
                    userType = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim();

                    if (userType == "administrator")
                    {
                        var resultArr = _UserDetailsBusinessLogic.GetAllUserGroups(isActive);
                        return(Json(resultArr));
                    }
                    else
                    {
                        var resultArr = _UserDetailsBusinessLogic.GetAllUserGroupsForOtherUser(isActive);
                        return(Json(resultArr));
                    }
                }
                else
                {
                    var resultArr = _UserDetailsBusinessLogic.GetAllUserGroupsForOtherUser(isActive);
                    return(Json(resultArr));
                }
            }
            catch (Exception ex)
            {
                currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, "UName", ex);
                return(Json(null));
            }
        }
        public ActionResult Index()
        {
            try
            {
                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                if (authCookie != null)
                {
                    _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();

                    FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);

                    ViewBag.ProfilePicURL = _UserDetailsBusinessLogic.GetUserDetails(ticket.Name)
                                            .FirstOrDefault().ProfilePicURL;
                    ViewBag.Username = ticket.Name;
                    ViewBag.UserType = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim();

                    return(View());
                }
                else
                {
                    this.HttpContext.Session["ErrorMsg"] = "LoginErr";
                    return(RedirectToAction("Index", "Login"));
                }
            }
            catch (Exception ex)
            {
                currentFile = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, "UName", ex);


                this.HttpContext.Session["ErrorMsg"] = "PageLoadError";
                return(RedirectToAction("Index", "LoginError"));
            }
        }
        public ActionResult Index(string requestId = null)
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();
                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                ViewBag.RequestId = requestId;
                bool isSessionTicketDecryptable = true;


                if (authCookie != null)
                {
                    try
                    {
                        ticket = FormsAuthentication.Decrypt(authCookie.Value);
                    }
                    catch (Exception ex)
                    {
                        isSessionTicketDecryptable = false;
                    }

                    if (isSessionTicketDecryptable == true)
                    {
                        ViewBag.ProfilePicURL = _UserDetailsBusinessLogic.GetUserDetails(ticket.Name)
                                                .FirstOrDefault().ProfilePicURL;
                        ViewBag.Username = ticket.Name;
                        ViewBag.UserType = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim();
                        return(View());
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Login", new RouteValueDictionary(new { id = "RedirectedLogin", userMsgRequestIdParam = requestId })));
                    }
                }
                else
                {
                    if (requestId != null)
                    {
                        return(RedirectToAction("Index", "Login", new RouteValueDictionary(new { id = "RedirectedLogin", userMsgRequestIdParam = requestId })));
                    }
                    else
                    {
                        this.HttpContext.Session["ErrorMsg"] = "LoginErr";
                        return(RedirectToAction("Index", "LoginError"));
                    }
                }
            }
            catch (Exception ex)
            {
                currentFile = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(1);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, "UName", ex);

                this.HttpContext.Session["ErrorMsg"] = "PageLoadError";
                return(RedirectToAction("Index", "LoginError"));
            }
        }