public static int Create(string name, string pwd, string email, string www) { return(UserData.Create(new UserEntity() { name = name, password = MU.MD5(pwd), email = email, www = www, avatar = " " })); }
/// <summary> /// 用户登录 /// </summary> /// <param name="name"></param> /// <param name="pwd"></param> /// <returns></returns> public static bool Login(string name, string pwd) { UserEntity entity = null; pwd = MU.MD5(pwd); try { if (name.Contains("@")) { entity = UserData.LoginByEmail(name, pwd); } else { entity = UserData.LoginByName(name, pwd); } //write cookie if (entity != null) { CacheService.Add(CNC.ACCOUNT_ENTITY_ID + entity.id, entity); string id = entity.id.ToString(); // id 仅作内部使用,不对外公开 QA.SetCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(new FormsAuthenticationTicket(1, id, DateTime.Now, DateTime.MaxValue, true, id, FormsAuthentication.FormsCookiePath)) , DateTime.MaxValue); //设置永久保留登录信息,之后版本可考虑进行配置 QA.SetCookie(SC.CN.A_NAME, HttpUtility.UrlEncode(entity.name), DateTime.MaxValue); string cookie = QA.GetCookie(SC.CN.FROM); //TODO: write log,add to task. Log.Login(entity); } } catch { } return(entity != null); }