public static AccountsPrincipal ValidateLoginEx(string userName, byte[] password, int cacheTime = 30) { IData.IUser dataUser = PubConstant.IsSQLServer ? (IUser) new Data.User() : new MySqlData.User(); try { if ((dataUser.ValidateLogin(userName, password)) > 0) { AccountsPrincipal accountsPrincipal = new AccountsPrincipal(userName, true); //存缓存 string CacheKey = "ValidateLoginEx-" + accountsPrincipal.Token; YSWL.Common.DataCache.SetCache(CacheKey, accountsPrincipal, DateTime.Now.AddMinutes(cacheTime), TimeSpan.Zero); return(accountsPrincipal); return(null); } else { return(null); } } catch (Exception ex) { Log.LogHelper.AddTextLog(ex.Message, ex.StackTrace); throw ex; } }
/// <summary> /// 验证登录信息 /// 邮箱登录 /// </summary> public static AccountsPrincipal ValidateLogin4Email(string email, string password) { int newID; byte[] cryptPassword = EncryptPassword(password); IData.IUser dataUser = PubConstant.IsSQLServer ? (IUser) new Data.User() : new MySqlData.User(); if ((newID = dataUser.ValidateLogin4Email(email, cryptPassword)) > 0) { return(new AccountsPrincipal(newID)); } else { return(null); } }
/// <summary> /// 根据角色ID构造角色的信息 /// </summary> public Role(int currentRoleId) { dataRole = PubConstant.IsSQLServer ? (IRole) new Data.Role() : new MySqlData.Role(); DataRow roleRow; roleRow = dataRole.Retrieve(currentRoleId); roleId = currentRoleId; if (roleRow["Description"] != null) { description = (string)roleRow["Description"]; } IData.IPermission dataPermission = PubConstant.IsSQLServer ? (IPermission) new Data.Permission() : new MySqlData.Permission(); permissions = dataPermission.GetPermissionList(currentRoleId); nopermissions = dataPermission.GetNoPermissionList(currentRoleId); IData.IUser user = PubConstant.IsSQLServer ? (IUser) new Data.User() : new MySqlData.User(); users = user.GetUsersByRole(currentRoleId); }