//Tam thoi khong luu tru thong tin cookie public DataRow LoginUser_Cookie(Dictionary <string, object> args) { FnCommon.ThrowInfoIsEmpty(args, "email", "Nhập vào thông tin Email!!!"); FnCommon.ThrowInfoIsEmpty(args, "pwd", "Nhập vào mật khẩu!!!"); bool saveCookie = false; #region RememberPwd if (FnCommon.TryGetValue(args, "isrememberpwd").ToLower() == "true") //Get pwd from cookie.Pwd is config empty in sql file { CookieAuthenticateModule cookieUser = new CookieAuthenticateModule(); Dictionary <string, object> dicUser = new Dictionary <string, object>(); try { dicUser = Tool.ToDic(cookieUser.GetUserMemoryUser()); args["pwd"] = dicUser["pwd"].ToString(); } catch { args["pwd"] = ""; } } else { args["pwd"] = FnSecurity.GeneratePassword(args["pwd"].ToString()); CookieAuthenticateModule cookieUser = new CookieAuthenticateModule(); cookieUser.ClearRememberUserMemory(); } //Save Cookie if (FnCommon.TryGetValue(args, "rememberpwd").ToLower() == "true") //Get pwd from cookie.Pwd is config empty in sql file { saveCookie = true; } #endregion DataRow dr = Tool.ToRow(DBHelper.Instance.Query("Apps.Manage.Base.Users.LoginUser", args)); if (dr == null) { CookieAuthenticateModule cookieUser = new CookieAuthenticateModule(); cookieUser.ClearUserMemory(); throw new NService.NSInfoException("Tài khoản đăng nhập hoặc mật khẩu không hợp lệ!!!"); } else { #region AutoLogin if (FnCommon.TryGetValue(args, "autologin").ToLower() == "true") //Load pwd from cookie { CookieAuthenticateModule cookieUser = new CookieAuthenticateModule(); cookieUser.SetAutoLogin(dr["user_id"].ToString()); } #endregion } NService.AuthenticateHelper.Instance.Login(dr["user_id"].ToString(), saveCookie); return(dr); }
const string _IV_64 = "b*2^)5[?"; //必須是8個字符(64Bit) public static string Decrypt(string from) { return(CookieAuthenticateModule.Decrypt(from, _KEY_64, _IV_64)); }
public Dictionary <string, object> RememerUserInfo(Dictionary <string, object> args) { CookieAuthenticateModule cookieUser = new CookieAuthenticateModule(); Dictionary <string, object> dicUser = new Dictionary <string, object>(); Dictionary <string, object> dicUserNew = new Dictionary <string, object>(); string UserID = AuthenticateHelper.Instance.UserID;//User da login roi cho phep dang nhap tu dong if (!string.IsNullOrEmpty(UserID)) { dicUserNew.Add("UserID", UserID); dicUserNew.Add("autologin", "true");//use cookie pwd return(dicUserNew); } return(null); #region AutoLogin /*try * { * string UserID = cookieUser.GetAutoLogin(); * if (!string.IsNullOrEmpty(UserID)) * { * dicUserNew.Add("UserID", UserID); * dicUserNew.Add("autologin", "true");//use cookie pwd * return dicUserNew; * } * * } * catch * { * return null; * }*/ #endregion #region RememberPwd /*try * { * dicUser = Tool.ToDic(cookieUser.GetUserMemoryUser()); * if (dicUser != null && dicUser.Count > 0) * { * dicUserNew.Add("email", dicUser["email"].ToString()); * dicUserNew.Add("pwd", "********"); * dicUserNew.Add("isrememberpwd", "true"); * dicUserNew.Add("rememberpwd", true); * return dicUserNew; * } * } * catch * { * return null; * }*/ #endregion return(null); }