コード例 #1
0
        // GET: Institute/LandingPage
        public ActionResult Index(string InstituteID = "", string User_id = "0")
        {
            InstituteRepository _objRepository = new InstituteRepository();
            InstituteMaster     _obj           = new InstituteMaster();

            _obj.InstituteID = InstituteID;
            DataSet ds = _objRepository.Login_Institute(_obj);

            if (ds != null)
            {
                Session["IsChangePwd"] = null;
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    Session["InstituteID"]    = dr["InstituteID"].ToString();
                    Session["InstituteName"]  = dr["InstituteName"].ToString();
                    Session["Email"]          = dr["Email"].ToString();
                    Session["User_id"]        = User_id;
                    Session["IsAdminFLag"]    = "True";
                    Session["IsAdminEdit"]    = "True";
                    Session["IsNicheAllowed"] = dr["IsNicheAllowed"].ToString();
                    string localIP = "?";
                    localIP                     = Request.ServerVariables["REMOTE_ADDR"].ToString();
                    Session["localIP"]          = localIP;
                    Session["InstituteType"]    = dr["InstituteType"].ToString();
                    Session["ParticipatedYear"] = ConfigurationManager.AppSettings["ParticipatedYear"].ToString();
                }
                if (ds.Tables[1].Rows.Count > 0)
                {
                    foreach (DataRow _dr in ds.Tables[1].Rows)
                    {
                        Session["AR_StartDate"] = _dr["MinDate"].ToString();
                        Session["AR_EndDate"]   = _dr["MaxDate"].ToString();
                    }
                }
                if (ds.Tables[2].Rows.Count > 0)
                {
                    foreach (DataRow _dr in ds.Tables[2].Rows)
                    {
                        Session["ParticipatedYear"] = _dr["ParticipatedYear"].ToString();
                    }
                }
                else
                {
                    Session["ParticipatedYear"] = "";
                }
            }
            //return RedirectToAction("Index", "Dashboard", new { area = "Institute" });
            return(Redirect("~/Institute/ParticipationYears"));
        }
コード例 #2
0
        public JsonResult CheckLogin(InstituteMaster _obj)
        {
            bool flagCaptcha         = false;
            bool flagLogin           = false;
            bool flagPasswordChanged = true;
            bool flagValidID         = false;

            try
            {
                if (this.Session["CaptchaImageText"].ToString() == _obj.Captchastr)
                {
                    flagCaptcha = true;
                    InstituteRepository _objRepository = new InstituteRepository();
                    DataSet             ds             = _objRepository.Login_Institute(_obj);
                    if (ds != null)
                    {
                        Session["IsChangePwd"] = null;
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            flagValidID = true;
                            DataRow dr       = ds.Tables[0].Rows[0];
                            string  Password = dr["Password"].ToString();
                            string  random   = "";
                            if (dr["DefaultPassword"] != null)
                            {
                                random = dr["DefaultPassword"].ToString();
                            }
                            if (dr["IsPasswordChanged"].ToString().ToLower() == "true")
                            {
                                //nvNHsQGCNC3Ph/TQRX3dbd4BnGKtXFV/Ow==
                                string PASSWORD = _obj.Password;
                                string MD5      = Helper.VerifyHash(PASSWORD, "MD5", Password).ToString();
                                string SHA1     = Helper.VerifyHash(PASSWORD, "SHA1", Password).ToString();
                                string sha256   = Helper.VerifyHash(PASSWORD, "SHA256", Password).ToString();
                                string sha384   = Helper.VerifyHash(PASSWORD, "SHA384", Password).ToString();
                                string sha512   = Helper.VerifyHash(PASSWORD, "SHA512", Password).ToString();
                                if (MD5 != "True" || SHA1 == "True" || sha256 == "True" || sha384 == "True" || sha512 == "True")
                                {
                                    TempData["old_password"] = PASSWORD;
                                    flagLogin = true;
                                }
                            }
                            else
                            {
                                if (random != "")
                                {
                                    if (random == _obj.Password)
                                    {
                                        flagLogin                = true;
                                        flagPasswordChanged      = false;
                                        TempData["old_password"] = random;
                                    }
                                }
                            }
                            if (flagLogin)
                            {
                                Session["InstituteID"]   = dr["InstituteID"].ToString();
                                Session["InstituteName"] = dr["InstituteName"].ToString();
                                Session["Email"]         = dr["Email"].ToString();
                                string localIP = "?";
                                localIP                     = Request.ServerVariables["REMOTE_ADDR"].ToString();
                                Session["localIP"]          = localIP;
                                Session["User_id"]          = "0";
                                Session["IsAdminFLag"]      = dr["IsAdminFLag"].ToString();
                                Session["IsAdminEdit"]      = dr["IsAdminEdit"].ToString();
                                Session["IsNicheAllowed"]   = dr["IsNicheAllowed"].ToString();
                                Session["InstituteType"]    = dr["InstituteType"].ToString();
                                Session["ParticipatedYear"] = ConfigurationManager.AppSettings["ParticipatedYear"].ToString();
                                flagLogin                   = true;
                            }
                        }
                        if (flagLogin)
                        {
                            if (ds.Tables[1].Rows.Count > 0)
                            {
                                foreach (DataRow _dr in ds.Tables[1].Rows)
                                {
                                    Session["AR_StartDate"] = _dr["MinDate"].ToString();
                                    Session["AR_EndDate"]   = _dr["MaxDate"].ToString();
                                }
                            }
                            if (ds.Tables[2].Rows.Count > 0)
                            {
                                foreach (DataRow _dr in ds.Tables[2].Rows)
                                {
                                    Session["ParticipatedYear"] = _dr["ParticipatedYear"].ToString();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(Json(new
            {
                flagCaptcha = flagCaptcha,
                flagLogin = flagLogin,
                flagPasswordChanged = flagPasswordChanged,
                flagValidID = flagValidID
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }
コード例 #3
0
        public JsonResult Check_And_ChangePassword(InstituteMaster _obj)
        {
            bool flagCheckPassword = false;
            bool flagCaptcha       = false;
            bool flagPwdChanged    = false;

            if (this.Session["CaptchaImageText"].ToString() == _obj.Captchastr)
            {
                flagCaptcha      = true;
                _obj.InstituteID = Session["InstituteID"].ToString();
                InstituteRepository _objRepository = new InstituteRepository();
                DataSet             ds             = _objRepository.Login_Institute(_obj);
                if (ds != null)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        DataRow dr             = ds.Tables[0].Rows[0];
                        string  actualPassword = dr["Password"].ToString();
                        string  random         = "";
                        if (dr["DefaultPassword"] != null)
                        {
                            random = dr["DefaultPassword"].ToString();
                        }
                        if (dr["IsPasswordChanged"].ToString().ToLower() == "true")
                        {
                            string password = _obj.DefaultPassword;
                            string MD5      = Helper.VerifyHash(password, "MD5", actualPassword).ToString();
                            string SHA1     = Helper.VerifyHash(password, "SHA1", actualPassword).ToString();
                            string sha256   = Helper.VerifyHash(password, "SHA256", actualPassword).ToString();
                            string sha384   = Helper.VerifyHash(password, "SHA384", actualPassword).ToString();
                            string sha512   = Helper.VerifyHash(password, "SHA512", actualPassword).ToString();

                            if (MD5 == "True" || SHA1 == "True" || sha256 == "True" || sha384 == "True" || sha512 == "True")
                            {
                                flagCheckPassword = true;
                            }
                        }
                        else
                        {
                            if (random != "")
                            {
                                if (random == _obj.DefaultPassword)
                                {
                                    flagCheckPassword = true;
                                }
                            }
                        }
                        if (flagCheckPassword)
                        {
                            Random rn = new Random();
#pragma warning disable SCS0005 // Weak random generator
                            int month = rn.Next(1, 6);
#pragma warning restore SCS0005 // Weak random generator
                            StringBuilder hashPassword = new StringBuilder();
                            string        new_password = _obj.Password;
                            switch (month)
                            {
                            case 1:
                                hashPassword.Append(Helper.ComputeHash(new_password, "MD5", null));
                                break;

                            case 2:
                                hashPassword.Append(Helper.ComputeHash(new_password, "SHA1", null));
                                break;

                            case 3:
                                hashPassword.Append(Helper.ComputeHash(new_password, "SHA256", null));
                                break;

                            case 4:
                                hashPassword.Append(Helper.ComputeHash(new_password, "SHA384", null));
                                break;

                            case 5:
                                hashPassword.Append(Helper.ComputeHash(new_password, "SHA512", null));
                                break;
                            }
                            _obj.Password = hashPassword.ToString();
                            DataSet _dsChngPwd = _objRepository.Institute_password_change(_obj);
                            if (_dsChngPwd != null)
                            {
                                if (_dsChngPwd.Tables[0].Rows.Count > 0)
                                {
                                    flagPwdChanged = true;
                                    Session["IsPasswordChanged"] = "true";
                                }
                            }
                        }
                    }
                }
            }
            return(Json(new
            {
                flagCaptcha = flagCaptcha,
                flagPwdChanged = flagPwdChanged
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }