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); }
private void DoRegister() { string account_name = Request["account_name"]; string email = Request["email"]; string pwd = Request["pwd"]; CDBUser usr = dbAdapter.FindUserByAlias(account_name); if (usr != null) { throw new Exception("Your alias is already used."); } usr = dbAdapter.FindUserByEmail(email); if (usr != null) { throw new Exception("Your email is already used."); } dbAdapter.AddUser(account_name, email, pwd); ErrorMsg = ChatSite.Constants.S_OK; }