public bool Authenticate(string Username, string Password) { //Create an authentication object user_auth user = new user_auth(); //Set the credentials user.user_name = Username; user.password = this.computeMD5String(Password); //Try to authenticate set_entry_result authentication_result = this.sugarClient.login(user, ""); //Check for errors if (Convert.ToInt32(authentication_result.error.number) != 0) { //An error occured this.error = String.Concat(authentication_result.error.name, ": ", authentication_result.error.description); //Clear the existing sessionId this.sessionId = String.Empty; } else { //Set the sessionId this.sessionId = authentication_result.id; //Clear the existing error this.error = String.Empty; } //Return the boolean return(this.sessionId != String.Empty); }
public bool Authenticate(string Username, string Password) { //Create an authentication object user_auth user = new user_auth(); //Set the credentials user.user_name = Username; user.password = this.computeMD5String(Password); //Try to authenticate set_entry_result authentication_result = this.sugarClient.login(user, ""); //Check for errors if (Convert.ToInt32(authentication_result.error.number) != 0) { //An error occured this.error = String.Concat(authentication_result.error.name, ": ", authentication_result.error.description); //Clear the existing sessionId this.sessionId = String.Empty; } else { //Set the sessionId this.sessionId = authentication_result.id; //Clear the existing error this.error = String.Empty; } //Return the boolean return (this.sessionId != String.Empty); }
public ActionResult Register_Email(Register_Email_Model model) { user user = new user(); entity.user.Add(user); entity.SaveChanges(); user_auth_state user_auth_state = new user_auth_state(); user_auth_state.access_failed_count = 0; user_auth_state.email_auth = false; user_auth_state.is_lockout = false; user_auth_state.phone_auth = false; user_auth_state.security_stamp = Guid.NewGuid().ToString("N"); user_auth_state.user_id = user.id; entity.user_auth_state.Add(user_auth_state); user_auth user_auth = new user_auth(); user_auth.user_id = user.id; user_auth.identity_type = IdentityType.email; user_auth.identifier = model.email; user_auth.credential = model.emailpassword; entity.user_auth.Add(user_auth); SignInManager.SignIn(user.id); if (entity.SaveChanges() > 0) { return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Error", "Home", new { errorMessage = "注册过程中发生意外" })); }
public bool SetUserToken(int userId, string token) { user_auth userAuth = new user_auth(); if (userAuth == null) { return false; } userAuth.user_id = (byte) userId; userAuth.token = token; userAuth.issued = DateTime.Now; try { _dbContext.user_auth.Add(userAuth); _dbContext.SaveChanges(); } catch (DbEntityValidationException ex) { Console.WriteLine(ex.Message); } return true; }
private string Login(string user, string pass, string version, string appName) { var auth = new user_auth(); set_entry_result result; string str = GetMD5Hash(pass); string id; auth.user_name = user; auth.password = str; auth.version = version; result = _sugarsoap.login(auth, appName); VerifySugarResult.Verify(result.error); return(result.id); }
private string Login(string user, string pass, string version, string appName) { var auth = new user_auth(); set_entry_result result; string str = GetMD5Hash(pass); string id; auth.user_name = user; auth.password = str; auth.version = version; result = _sugarsoap.login(auth, appName); VerifySugarResult.Verify(result.error); return result.id; }
public set_entry_result login(user_auth user_auth, string application_name) { // 03/12/2007 Paul. If we are using NTLM, then the user_name will be blank. // This could be one of the reasons why some sessions were dying. if ( Security.IsWindowsAuthentication() ) { string[] arrUserName = HttpContext.Current.User.Identity.Name.Split('\\'); string sUSER_DOMAIN = arrUserName[0]; user_auth.user_name = arrUserName[1]; } // 12/29/2005 Paul. create_session returns "Suceess". We need a separate operation to get the SessionID. set_entry_result result = new set_entry_result(); // 06/04/2007 Paul. Use new function that returns the Session ID. result.id = CreateSession(user_auth.user_name, user_auth.password).ToString(); //result.id = Sql.ToString(HttpContext.Current.Cache.Get("soap.username.session." + user_auth.user_name.ToLower())); return result; }
public set_entry_result login(user_auth user_auth, string application_name) { object[] results = this.Invoke("login", new object[] { user_auth, application_name}); return ((set_entry_result)(results[0])); }
public set_entry_result login(user_auth user_auth, string application_name) { create_session(user_auth.user_name, user_auth.password); // 12/29/2005 Paul. create_session returns "Suceess". We need a separate operation to get the SessionID. set_entry_result result = new set_entry_result(); result.id = Sql.ToString(HttpContext.Current.Cache.Get("soap.username.session." + user_auth.user_name.ToLower())); return result; }