コード例 #1
0
        private void DoSignin(string account, string pwd)
        {
            if (String.IsNullOrEmpty(account))
            {
                throw new Exception("Input the account name or email");
            }

            if (String.IsNullOrEmpty(pwd))
            {
                throw new Exception("Input the password.");
            }

            CDBUser usr = null;

            if (RegexUtility.IsValidEmail(account))
            {
                usr = dbAdapter.FindUserByEmail(account);
            }
            else
            {
                usr = dbAdapter.FindUserByAlias(account);
            }

            if (usr == null)
            {
                throw new Exception("Not registered account.");
            }

            if (pwd != usr.pwd)
            {
                throw new Exception("Password invalid");
            }

            CSessionMgr.Login(usr.id, usr.alias);
        }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: liangzhengai/ChatSite
        protected void Page_Load(object sender, EventArgs e)
        {
            bool bLogin = CSessionMgr.IsLogined();

            if (!bLogin)
            {
                Response.Redirect("User/SignIn.aspx");
            }
        }
コード例 #3
0
        protected override void Run(object sender, EventArgs e)
        {
            string action       = Request["action"];
            string account_name = Request["account_name"];
            string pwd          = Request["pwd"];

            if (action == "signin")
            {
                DoSignin(account_name, pwd);
                Response.Redirect(ResolveUrl("~/Default.aspx"));
            }
            else if (action == "signout")
            {
                CSessionMgr.Logout();
            }
        }