/// <summary> /// 将授权用户加入在线列表 /// </summary> /// <param name="authenUser"></param> /// <returns></returns> public static AuthenUser PushAuthenUserOnline(AuthenUser authenUser) { string loginName = authenUser.LoginName.ToUpper(); if (AuthenUser.OnlineAuthenUserList.ContainsKey(loginName)) { return(AuthenUser.OnlineAuthenUserList[loginName] as AuthenUser); } AuthenUser.OnlineAuthenUserList.Add(loginName, authenUser); return(authenUser); }
/// <summary> /// 用于记录已登录用户的日志 /// </summary> /// <param name="logType"></param> /// <param name="opName"></param> /// <param name="opDesc"></param> public static void WriteLog(LogType logType, String opName, String opDesc) { AuthenUser admin = AuthenUser.GetCurrentUser(); if (admin == null) { AlertLogout(); } else { WriteLog(logType, opName, opDesc, admin.UserID, admin.LoginName); } }
/// <summary> /// 验证用户的口令 /// </summary> /// <param name="userName"></param> /// <param name="passWord"></param> /// <returns></returns> public static AuthenUser CheckUserPasswrod(string userName, string passWord) { AuthenUser admin = GetAuthenUserByLoginName(userName); if (admin != null && admin.PassWord == AdapterHelper.Hash(passWord)) { return(PushAuthenUserOnline(admin)); } else { return(null); } }
/// <summary> /// 获取到当前用户 /// </summary> /// <returns></returns> public static AuthenUser GetCurrentUser() { HttpCookie authCookies = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookies == null || String.IsNullOrEmpty(authCookies.Value)) { return(null); } else { FormsAuthenticationTicket authenTicket = FormsAuthentication.Decrypt(authCookies.Value); return(AuthenUser.AutoLogin(authenTicket.Name)); } }
/// <summary> /// 用户到授权用户的装换 /// </summary> /// <param name="person"></param> /// <returns></returns> public static AuthenUser TransformToAuthenUser(YouthOneDS.SystemAdminRow admin) { if (admin == null) { return(null); } AuthenUser authenUser = new AuthenUser(); authenUser.IsSystemAdmin = admin.LOG_NAME == "admin"; authenUser.UserID = admin.OID; authenUser.UserName = admin.LOG_NAME; authenUser.LoginName = admin.LOG_NAME; authenUser.PassWord = admin.PAS_WORD; authenUser.YouthGroup = admin.YG_OID; authenUser.RoleName = admin.ROL_NAME; return(authenUser); }
/// <summary> /// 根据Cookies中的用户名自动登录 /// </summary> public static AuthenUser AutoLogin(string userName) { AuthenUser admin = GetAuthenUserByLoginName(userName); return(PushAuthenUserOnline(admin)); }