public APILogin(string email, string password) { if (string.IsNullOrEmpty(email)) throw new ArgumentNullException("Email can't be NULL or empty."); // Create a User instance _UserInfo = new User(); _UserInfo.LoginEmail = email; _Password = password; }
private void GetPrincipal() { try { DateTime currentTime = DateTime.Now; HttpCookie cookie; cookie = HttpContext.Current.Request.Cookies[GlobalStatics.CookieName]; #region If is local machine, use localuser if (HttpContext.Current.Request.IsLocal) { bool[] m1 = new bool[32]; bool[] m2 = new bool[32]; for (int i = 0; i < m1.Length; i++) { m1[i] = true; m2[i] = true; } _APIUserPrincipal = new APIPrincipal(LocalUserId, LocalUserLoginEmail, m1, m2); HttpContext.Current.User = _APIUserPrincipal; UserManager userManager = new UserManager(); _User = userManager.GetUserbyId(ConfigurationManager.AppSettings["LocalUserId"]); _User.Roles = new UserManager().GetUserRoles(ConfigurationManager.AppSettings["LocalUserId"]); this.SavePrin(_APIUserPrincipal); this.CheckPermittedRole(); //this.CheckEnvironment(); return; } #endregion disable EdgarAuth for special needs //Log.Debug(cookie); GlobalStatics.MonitorProcessTime("First log", ref currentTime, DateTime.Now); if (cookie != null) { _User = GetUserFromCookie(); if (_User != null) { this.CheckPermittedRole(); //this.CheckEnvironment(); } else { this.GoToLogin(); //Log.Error("Failed to get auth info from cookie."); } } else { this.GoToLogin(); } GlobalStatics.MonitorProcessTime("EndAuthenticate", ref currentTime, DateTime.Now); } catch (Exception ex) { //Log.Error(ex); throw ex; } }
private void Process4ExistedGLUser(ref string msg, ref bool isLoginSuccess) { if (new UserManager().GetUserByEmail(_UserInfo.LoginEmail) != null) { int effectedRow = new UserManager().UpdateUserIdByEmail(_UserInfo.LoginEmail, _APIUserPrincipal.Guid); if (effectedRow <= 0) { //Log.Error("No data effected at Id:" + _UserInfo.LoginEmail); msg = "Failed to update account in Equity API Database."; isLoginSuccess = false; } else { _UserInfo = new UserManager().GetUserbyId(_APIUserPrincipal.Guid); if (_UserInfo != null) { _UserInfo.Roles = new UserManager().GetUserRoles(this._APIUserPrincipal.Guid); _UserInfo.Password = _Password; //UpdateUserNotificationMessage(_UserInfo.UserId); isLoginSuccess = true; } else { isLoginSuccess = false; msg = "Failed to get User entity by UserId."; } } } else { msg = "Your account was not existed in Equity API Database."; isLoginSuccess = false; } }
private void Process4ExistedAPIUser(ref string msg, ref bool isLoginSuccess, ref DateTime startTime, User existedUser) { existedUser.Roles = new UserManager().GetUserRoles(this._APIUserPrincipal.Guid); GlobalStatics.MonitorProcessTime("Get role from DB", ref startTime, DateTime.Now); existedUser.Password = _Password; isLoginSuccess = true; _UserInfo = existedUser; }