public ActionResult SignUp(AccountRegistration information) { var username = new Username(information.Username); bool usernameIsAvailable = _accountRegistrationService.IsUsernameAvailable(username); if (!usernameIsAvailable) { TempData.RegistrationFailureReason.Store(RegistrationFailureReason.UsernameNotAvailable); TempData.AccountRegistrationInformation.Store(information); return RedirectToAction<AccountController>(c => c.SignUp()); } var password = new Password(information.Password); var passwordConfirmation = new Password(information.PasswordConfirmation); if (!password.Equals(passwordConfirmation)) { TempData.RegistrationFailureReason.Store(RegistrationFailureReason.PasswordsDoNotMatch); return RedirectToAction<AccountController>(c => c.SignUp()); } var emailAddress = new EmailAddress(information.Email); var emailAddressConfirmation = new EmailAddress(information.EmailConfirmation); if (!emailAddress.Equals(emailAddressConfirmation)) { TempData.RegistrationFailureReason.Store(RegistrationFailureReason.EmailsDoNotMatch); return RedirectToAction<AccountController>(c => c.SignUp()); } var foo = new GivenNames(); var fullName = new FullName(new Name(information.LastName), new GivenNames(information.FirstName)); var accountRegistration = new AccountManagement.AccountRegistration(username, password, fullName, new EmailAddress(information.Email)); _accountRegistrationService.CreateAccount(accountRegistration); TempData.NewAccountUsername.Store(accountRegistration.Username); return RedirectToAction<AccountController>(c => c.SignUpComplete()); }
public AccountRegistration(Username username, Password password, FullName fullName, EmailAddress email) { Email = email; Username = username; Password = password; FullName = fullName; }
public void Ctor_withValidArgs_works(EventType type) { // arrange: List<object> mocks = new List<object>(); Username userId = new Username("Giacomo"); IUser user = MockRepository.GenerateStrictMock<IUser>(); user.Expect(u => u.Username).Return(userId).Repeat.Once(); mocks.Add(user); TrackingId cargoId = new TrackingId("CARGO001"); UnLocode location = new UnLocode("UNLOC"); VoyageNumber voyage = new VoyageNumber("VYG001"); ICargo cargo = MockRepository.GenerateStrictMock<ICargo>(); cargo.Expect(c => c.TrackingId).Return(cargoId).Repeat.Once(); IDelivery delivery = MockRepository.GenerateStrictMock<IDelivery>(); delivery.Expect(d => d.LastKnownLocation).Return(location).Repeat.Once(); delivery.Expect(d => d.CurrentVoyage).Return(voyage).Repeat.Once(); mocks.Add(delivery); cargo.Expect(c => c.Delivery).Return(delivery).Repeat.Twice(); mocks.Add(cargo); DateTime completionDate = DateTime.UtcNow; // act: IEvent underTest = new Event(user, cargo, type, completionDate); // assert: Assert.AreSame(userId, underTest.User); Assert.AreSame(cargoId, underTest.Cargo); Assert.AreSame(location, underTest.Location); Assert.AreSame(voyage, underTest.Voyage); Assert.AreEqual(completionDate, underTest.Date); Assert.AreEqual(type, underTest.Type); foreach(object mock in mocks) mock.VerifyAllExpectations(); }
public AccountManagement.Account FindAccount(Username username) { using (var db = new THCard()) { Account dbAccount = FindAccountByUsername(username, db); if (dbAccount == null) { return null; } return MapAccount(dbAccount); } }
public Account(AccountId accountId, Username username, AccountRoles roles) { Contract.Requires(accountId != null); Contract.Requires(username != null); Contract.Requires(roles != null); AccountId = accountId; Username = username; _roles = roles; }
public Event (IUser user, ICargo cargo, EventType type, DateTime completionDate) { if(null == user) throw new ArgumentNullException("user"); if(null == cargo) throw new ArgumentNullException("cargo"); _user = user.Username; _completionDate = completionDate; _cargo = cargo.TrackingId; _location = cargo.Delivery.LastKnownLocation; _voyage = cargo.Delivery.CurrentVoyage; _type = type; }
public LoginAttemptResult Authenticate(Username username, Password password) { Contract.Ensures(Contract.Result<LoginAttemptResult>().Succeeded == false || Contract.Result<LoginAttemptResult>().Account != null); Account account = _accountRepository.FindAccount(username); if (account == null) { return LoginAttemptResult.UsernameNotFound(); } SaltedHash accountPasswordHash = _accountRepository.GetAccountPassword(account.AccountId); bool passwordMatches = new Hasher().Matches(password.ToString(), accountPasswordHash); if (!passwordMatches) { int failedLoginAttemptCount = _accountRepository.IncrementFailedLoginAttemptCount(account.AccountId); return LoginAttemptResult.IncorrectPassword(failedLoginAttemptCount); } return LoginAttemptResult.Success(account); }
public void EnterCredentials(string username, string password) { Username.SendKeys(username + Keys.Tab); Password.SendKeys(password + Keys.Tab); }
private static Account FindAccountByUsername(Username username, THCard db) { string usernameAsString = username.ToString(); return db.Accounts.FirstOrDefault(a => a.Username == usernameAsString); }
public override int GetHashCode() { int hash = 1; if (CreationTimestampMs != 0L) { hash ^= CreationTimestampMs.GetHashCode(); } if (Username.Length != 0) { hash ^= Username.GetHashCode(); } if (Team != 0) { hash ^= Team.GetHashCode(); } hash ^= tutorialState_.GetHashCode(); if (avatar_ != null) { hash ^= Avatar.GetHashCode(); } if (MaxPokemonStorage != 0) { hash ^= MaxPokemonStorage.GetHashCode(); } if (MaxItemStorage != 0) { hash ^= MaxItemStorage.GetHashCode(); } if (dailyBonus_ != null) { hash ^= DailyBonus.GetHashCode(); } if (equippedBadge_ != null) { hash ^= EquippedBadge.GetHashCode(); } if (contactSettings_ != null) { hash ^= ContactSettings.GetHashCode(); } hash ^= currencies_.GetHashCode(); if (RemainingCodenameClaims != 0) { hash ^= RemainingCodenameClaims.GetHashCode(); } if (buddyPokemon_ != null) { hash ^= BuddyPokemon.GetHashCode(); } if (BattleLockoutEndMs != 0L) { hash ^= BattleLockoutEndMs.GetHashCode(); } if (secondaryPlayerAvatar_ != null) { hash ^= SecondaryPlayerAvatar.GetHashCode(); } if (NameIsBlacklisted != false) { hash ^= NameIsBlacklisted.GetHashCode(); } return(hash); }
private void btn_login_Click(object sender, EventArgs e) { if (Username.Text.Trim(' ').Length == 0) { MessageBox.Show("Please enter user id", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); Username.Focus(); return; } if (Username.Text.Trim(' ').Length == 0) { MessageBox.Show("Please enter password", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); Password.Focus(); return; } try { ModCommonClasses.con = new SqlConnection(ModCS.cs); ModCommonClasses.con.Open(); ModCommonClasses.cmd = ModCommonClasses.con.CreateCommand(); ModCommonClasses.cmd.CommandText = "SELECT RTRIM(UserID),RTRIM(Password) FROM tbl_login where UserType = @d1 and Name = @d2 and Password=@d3 and Active='Yes'"; ModCommonClasses.cmd.Parameters.AddWithValue("@d1", combo_type.Text); ModCommonClasses.cmd.Parameters.AddWithValue("@d2", Username.Text); ModCommonClasses.cmd.Parameters.AddWithValue("@d3", ModFunc.Encrypt(Password.Text)); ModCommonClasses.rdr = ModCommonClasses.cmd.ExecuteReader(); if (ModCommonClasses.rdr.Read()) { ModCommonClasses.con = new SqlConnection(ModCS.cs); ModCommonClasses.con.Open(); ModCommonClasses.cmd = ModCommonClasses.con.CreateCommand(); ModCommonClasses.cmd.CommandText = "SELECT usertype FROM tbl_login where UserType=@d4 and Name=@d5 and Password=@d6"; ModCommonClasses.cmd.Parameters.AddWithValue("@d4", combo_type.Text); ModCommonClasses.cmd.Parameters.AddWithValue("@d5", Username.Text); ModCommonClasses.cmd.Parameters.AddWithValue("@d6", ModFunc.Encrypt(Password.Text)); ModCommonClasses.rdr = ModCommonClasses.cmd.ExecuteReader(); if (ModCommonClasses.rdr.Read()) { } if (ModCommonClasses.rdr != null) { ModCommonClasses.rdr.Close(); } if (ModCommonClasses.con.State == ConnectionState.Open) { ModCommonClasses.con.Close(); } string st = "Successfully logged in"; ModFunc.LogFunc(Username.Text, st); this.Hide(); Dashboard ss = new Dashboard(); ss.Show(); ss.lblUser.Text = Username.Text; ss.lblUserType.Text = combo_type.Text; } else { Interaction.MsgBox("Login is Failed...Try again !", MsgBoxStyle.Critical, "Login Denied"); Username.Text = ""; Password.Text = ""; Username.Focus(); } ModCommonClasses.cmd.Dispose(); ModCommonClasses.con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public override string ToString() { return(Username.ToString()); }
public async Task <JsonResult> OnPostCheckUserName() { Artist username = _userManager.Users.FirstOrDefault(x => x.UserName == Username.ToLower() || x.NormalizedUserName.ToLower() == Username.ToLower()); return(new JsonResult((username != null && username != await _userManager.GetUserAsync(User)) ? false : true)); }
public UsernameAlreadyExistException(Username username) : base($"'{username}' already exist") { }
public List <Gump> ReadGumps() { string path = FileSystemHelper.CreateFolderIfNotExists(ProfilePath, Username.Trim(), ServerName.Trim(), CharacterName.Trim()); List <Gump> gumps = new List <Gump>(); // ######################################################### // [FILE_FIX] // TODO: this code is a workaround to port old macros to the new xml system. string skillsGroupsPath = Path.Combine(path, "skillsgroups.bin"); if (File.Exists(skillsGroupsPath)) { try { using (BinaryReader reader = new BinaryReader(File.OpenRead(skillsGroupsPath))) { int version = reader.ReadInt32(); int groupCount = reader.ReadInt32(); for (int i = 0; i < groupCount; i++) { int entriesCount = reader.ReadInt32(); string groupName = reader.ReadUTF8String(reader.ReadInt32()); SkillsGroup g = new SkillsGroup(); g.Name = groupName; for (int j = 0; j < entriesCount; j++) { byte idx = (byte)reader.ReadInt32(); g.Add(idx); } g.Sort(); SkillsGroupManager.Add(g); } } } catch (Exception e) { SkillsGroupManager.MakeDefault(); Log.Error(e.StackTrace); } SkillsGroupManager.Save(); try { File.Delete(skillsGroupsPath); } catch { } } string binpath = Path.Combine(path, "gumps.bin"); if (File.Exists(binpath)) { using (BinaryReader reader = new BinaryReader(File.OpenRead(binpath))) { if (reader.BaseStream.Position + 12 < reader.BaseStream.Length) { GumpsVersion = reader.ReadUInt32(); uint empty = reader.ReadUInt32(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { try { int typeLen = reader.ReadUInt16(); string typeName = reader.ReadUTF8String(typeLen); int x = reader.ReadInt32(); int y = reader.ReadInt32(); Type type = Type.GetType(typeName, true); Gump gump = (Gump)Activator.CreateInstance(type); gump.Restore(reader); gump.X = x; gump.Y = y; //gump.SetInScreen(); if (gump.LocalSerial != 0) { UIManager.SavePosition(gump.LocalSerial, new Point(x, y)); } if (!gump.IsDisposed) { gumps.Add(gump); } } catch (Exception e) { Log.Error(e.StackTrace); } } } } SaveGumps(path, gumps); gumps.Clear(); try { File.Delete(binpath); } catch { } } // ######################################################### // load skillsgroup //SkillsGroupManager.Load(); SkillsGroupManager.Load(); // load gumps string gumpsXmlPath = Path.Combine(path, "gumps.xml"); if (File.Exists(gumpsXmlPath)) { XmlDocument doc = new XmlDocument(); try { doc.Load(gumpsXmlPath); } catch (Exception ex) { Log.Error(ex.ToString()); return(gumps); } XmlElement root = doc["gumps"]; if (root != null) { foreach (XmlElement xml in root.GetElementsByTagName("gump")) { try { GUMP_TYPE type = (GUMP_TYPE)int.Parse(xml.GetAttribute("type")); int x = int.Parse(xml.GetAttribute("x")); int y = int.Parse(xml.GetAttribute("y")); uint serial = uint.Parse(xml.GetAttribute("serial")); Gump gump = null; switch (type) { case GUMP_TYPE.GT_BUFF: gump = new BuffGump(); break; case GUMP_TYPE.GT_CONTAINER: gump = new ContainerGump(); break; case GUMP_TYPE.GT_COUNTERBAR: gump = new CounterBarGump(); break; case GUMP_TYPE.GT_HEALTHBAR: if (CustomBarsToggled) { gump = new HealthBarGumpCustom(); } else { gump = new HealthBarGump(); } break; case GUMP_TYPE.GT_INFOBAR: gump = new InfoBarGump(); break; case GUMP_TYPE.GT_JOURNAL: gump = new JournalGump(); break; case GUMP_TYPE.GT_MACROBUTTON: gump = new MacroButtonGump(); break; case GUMP_TYPE.GT_MINIMAP: gump = new MiniMapGump(); break; case GUMP_TYPE.GT_PAPERDOLL: gump = new PaperDollGump(); break; case GUMP_TYPE.GT_SKILLMENU: if (StandardSkillsGump) { gump = new StandardSkillsGump(); } else { gump = new SkillGumpAdvanced(); } break; case GUMP_TYPE.GT_SPELLBOOK: gump = new SpellbookGump(); break; case GUMP_TYPE.GT_STATUSGUMP: switch (Settings.GlobalSettings.ShardType) { default: case 0: // modern gump = new StatusGumpModern(); break; case 1: // old gump = new StatusGumpOld(); break; case 2: // outlands gump = new StatusGumpOutlands(); break; } break; //case GUMP_TYPE.GT_TIPNOTICE: // gump = new TipNoticeGump(); // break; case GUMP_TYPE.GT_ABILITYBUTTON: gump = new UseAbilityButtonGump(); break; case GUMP_TYPE.GT_SPELLBUTTON: gump = new UseSpellButtonGump(); break; case GUMP_TYPE.GT_SKILLBUTTON: gump = new SkillButtonGump(); break; case GUMP_TYPE.GT_RACIALBUTTON: gump = new RacialAbilityButton(); break; case GUMP_TYPE.GT_WORLDMAP: gump = new WorldMapGump(); break; } if (gump == null) { continue; } gump.LocalSerial = serial; gump.Restore(xml); gump.X = x; gump.Y = y; if (gump.LocalSerial != 0) { UIManager.SavePosition(gump.LocalSerial, new Point(x, y)); } if (!gump.IsDisposed) { gumps.Add(gump); } } catch (Exception ex) { Log.Error(ex.ToString()); } } } } // load anchors string anchorsPath = Path.Combine(path, "anchors.bin"); if (File.Exists(anchorsPath)) { try { using (BinaryReader reader = new BinaryReader(File.OpenRead(anchorsPath))) UIManager.AnchorManager.Restore(reader, gumps); } catch (Exception e) { Log.Error(e.StackTrace); } } return(gumps); }
public void AboutBlockchange(Player p, ushort x, ushort y, ushort z, byte type) { if (!p.staticCommands) { p.ClearBlockchange(); } byte b = p.level.GetTile(x, y, z); if (b == Block.Zero) { Player.SendMessage(p, "Invalid Block(" + x + "," + y + "," + z + ")!"); return; } p.SendBlockchange(x, y, z, b); string message = "Block (" + x + "," + y + "," + z + "): "; message += "&f" + b + " = " + Block.Name(b); Player.SendMessage(p, message + Server.DefaultColor + "."); message = p.level.foundInfo(x, y, z); if (message != "") { Player.SendMessage(p, "Physics information: &a" + message); } DataTable Blocks = Server.useMySQL ? MySQL.fillData("SELECT * FROM `Block" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z) : SQLite.fillData("SELECT * FROM Block" + p.level.name + " WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z); string Username, TimePerformed, BlockUsed; bool Deleted, foundOne = false; for (int i = 0; i < Blocks.Rows.Count; i++) { foundOne = true; Username = Blocks.Rows[i]["Username"].ToString(); TimePerformed = DateTime.Parse(Blocks.Rows[i]["TimePerformed"].ToString()).ToString("yyyy-MM-dd HH:mm:ss"); //Server.s.Log(Blocks.Rows[i]["Type"].ToString()); BlockUsed = Block.Name(Convert.ToByte(Blocks.Rows[i]["Type"])).ToString(); Deleted = Convert.ToBoolean(Blocks.Rows[i]["Deleted"]); if (!Deleted) { Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed); } else { Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed); } Player.SendMessage(p, "Date and time modified: &2" + TimePerformed); } List <Level.BlockPos> inCache = p.level.blockCache.FindAll(bP => bP.x == x && bP.y == y && bP.z == z); for (int i = 0; i < inCache.Count; i++) { foundOne = true; Deleted = inCache[i].deleted; Username = inCache[i].name; TimePerformed = inCache[i].TimePerformed.ToString("yyyy-MM-dd HH:mm:ss"); BlockUsed = Block.Name(inCache[i].type); if (!Deleted) { Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed); } else { Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed); } Player.SendMessage(p, "Date and time modified: &2" + TimePerformed); } if (!foundOne) { Player.SendMessage(p, "This block has not been modified since the map was cleared."); } Blocks.Dispose(); GC.Collect(); GC.WaitForPendingFinalizers(); }
public CreateAccessTokenCommand(Username username, Password password) { Username = username; Password = password; }
public override bool Equals(object obj) { Album album = obj as Album; return(Username.Equals(album.Username) && Path.Equals(album.Path)); }
static void Main(string[] args) { var user01Obj = new Username("Admin", "123456", "p203"); }
public override int GetHashCode() => ChannelId.GetHashCode() ^ Username.GetHashCode() ^ Type.GetHashCode();
public void FocusUsername(object sender, EventArgs args) { Username.Focus(); }
private bool VerifyFields() { // check username if (String.IsNullOrEmpty(Username.Text)) { MOG_Prompt.PromptResponse("Missing Data", "Please enter a user name"); Username.Focus(); return(false); } if (Email.Text.IndexOf(" ") != -1) { MOG_Prompt.PromptResponse("Invalid Character", "Email addresses cannot contian spaces"); Email.Focus(); return(false); } if (MOG_ControllerSystem.InvalidMOGCharactersCheck(Username.Text, false)) { MOG_Prompt.PromptResponse("Please fix the user name", "Invalid Character in user name. Fix this and try again."); Username.Focus(); return(false); } if (String.IsNullOrEmpty(Departments.Text)) { MOG_Prompt.PromptResponse("Missing Data", "Please enter a user category"); Departments.Focus(); return(false); } if (String.IsNullOrEmpty(Privileges.Text)) { MOG_Prompt.PromptResponse("Missing Data", "Please enter a user privilege group"); Privileges.Focus(); return(false); } // fixup hand-entered bless target foreach (string blessTarget in BlessTargets.Items) { if (String.Compare(blessTarget, BlessTargets.Text, true) == 0) { BlessTargets.SelectedItem = blessTarget; } } if (String.Compare(BlessTargets.Text, Username.Text, true) == 0 && !BlessTargets.Items.Contains(Username.Text)) { BlessTargets.Items.Add(Username.Text); BlessTargets.SelectedItem = Username.Text; } if (String.IsNullOrEmpty(BlessTargets.SelectedItem as string)) { MOG_Prompt.PromptResponse("Missing Data", "Please enter a user bless target"); BlessTargets.Focus(); return(false); } return(true); }
/// <summary>Parse accepts an XmlNode and parses values</summary> public void Parse(XmlNode xNode) { XmlNode xResultNode = null; string strTmp = null; try { xResultNode = xNode.SelectSingleNode(TAG_USER_ID); strTmp = xResultNode.InnerText; UserID = (long)Convert.ToInt32(strTmp); } catch { } try { xResultNode = xNode.SelectSingleNode(TAG_USER_ROLE_ID); UserRoleID = (long)Convert.ToInt32(xResultNode.InnerText); } catch { UserRoleID = 0; } try { xResultNode = xNode.SelectSingleNode(TAG_BEGIN_DATE_CREATED); BeginDateCreated = DateTime.Parse(xResultNode.InnerText); } catch { } try { xResultNode = xNode.SelectSingleNode(TAG_END_DATE_CREATED); EndDateCreated = DateTime.Parse(xResultNode.InnerText); } catch { } try { xResultNode = xNode.SelectSingleNode(TAG_BEGIN_DATE_MODIFIED); BeginDateModified = DateTime.Parse(xResultNode.InnerText); } catch { } try { xResultNode = xNode.SelectSingleNode(TAG_END_DATE_MODIFIED); EndDateModified = DateTime.Parse(xResultNode.InnerText); } catch { } try { xResultNode = xNode.SelectSingleNode(TAG_FIRSTNAME); Firstname = xResultNode.InnerText; if (Firstname.Trim().Length == 0) { Firstname = null; } } catch { Firstname = null; } try { xResultNode = xNode.SelectSingleNode(TAG_MIDDLENAME); Middlename = xResultNode.InnerText; if (Middlename.Trim().Length == 0) { Middlename = null; } } catch { Middlename = null; } try { xResultNode = xNode.SelectSingleNode(TAG_LASTNAME); Lastname = xResultNode.InnerText; if (Lastname.Trim().Length == 0) { Lastname = null; } } catch { Lastname = null; } try { xResultNode = xNode.SelectSingleNode(TAG_USERNAME); Username = xResultNode.InnerText; if (Username.Trim().Length == 0) { Username = null; } } catch { Username = null; } try { xResultNode = xNode.SelectSingleNode(TAG_PASSWD); Passwd = xResultNode.InnerText; if (Passwd.Trim().Length == 0) { Passwd = null; } } catch { Passwd = null; } try { xResultNode = xNode.SelectSingleNode(TAG_PICTURE_URL); PictureUrl = xResultNode.InnerText; if (PictureUrl.Trim().Length == 0) { PictureUrl = null; } } catch { PictureUrl = null; } // Cannot reliably convert a byte[] to a string. try { xResultNode = xNode.SelectSingleNode(TAG_IS_DISABLED); IsDisabled = Convert.ToBoolean(xResultNode.InnerText); } catch { IsDisabled = false; } try { xResultNode = xNode.SelectSingleNode(TAG_BEGIN_LAST_LOGIN_DATE); BeginLastLoginDate = DateTime.Parse(xResultNode.InnerText); } catch { } try { xResultNode = xNode.SelectSingleNode(TAG_END_LAST_LOGIN_DATE); EndLastLoginDate = DateTime.Parse(xResultNode.InnerText); } catch { } }
public override int GetHashCode() { return(Username.GetHashCode()); }
public UserLogin(Username username, Password password) { Username = username; Password = password; }
protected override void Execute(CodeActivityContext context) { System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; string userName; string password; userName = Username.Get(context); //username from context password = Password.Get(context) + SecurityToken.Get(context); //password+token from context SforceService SfdcBinding = null; LoginResult CurrentLoginResult = null; SfdcBinding = new SforceService(); try { CurrentLoginResult = SfdcBinding.login(userName, password); } catch (System.Web.Services.Protocols.SoapException e) { // This is likley to be caused by bad username or password SfdcBinding = null; throw (e); } catch (Exception e) { // This is something else, probably comminication SfdcBinding = null; throw (e); } //Change the binding to the new endpoint SfdcBinding.Url = CurrentLoginResult.serverUrl; //Console.WriteLine(SfdcBinding.Url); //Console.ReadLine(); //Create a new session header object and set the session id to that returned by the login SfdcBinding.SessionHeaderValue = new SessionHeader(); SfdcBinding.SessionHeaderValue.sessionId = CurrentLoginResult.sessionId; String[] fieldNames = FieldNames.Get(context); String[] fieldValues = FieldValues.Get(context); sObject obj = new sObject(); System.Xml.XmlElement[] objFields = new System.Xml.XmlElement[fieldNames.Length]; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); for (int i = 0; i < fieldNames.Length; i++) { objFields[i] = doc.CreateElement(fieldNames[i]); } for (int j = 0; j < fieldValues.Length; j++) { objFields[j].InnerText = fieldValues[j]; } obj.type = ObjectName.Get(context); obj.Any = objFields; sObject[] objList = new sObject[1]; objList[0] = obj; UpsertResult[] results = SfdcBinding.upsert(ExternalIDFieldName.Get(context), objList); for (int j = 0; j < results.Length; j++) { if (results[j].success) { RecordID.Set(context, "Record Created/Updated for ID: " + results[j].id); } else { // There were errors during the create call, // go through the errors array and write // them to the console String error; for (int i = 0; i < results[j].errors.Length; i++) { Error err = results[j].errors[i]; error = "Errors was found on item " + j.ToString() + Environment.NewLine + "Error code is: " + err.statusCode.ToString() + Environment.NewLine + "Error message: " + err.message; RecordID.Set(context, error); } } } }
private void BtnLogin_Click(object sender, EventArgs e) { try { if (LoginSuccess) { ClientForm clientForm = new ClientForm(Examcode.Trim(), PaperNo.Trim(), Username.Trim(), json, restoreCheckBox.Checked); clientForm.Show(); Hide(); } else { MessageBox.Show("Login Failed"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary>把消息写入到数据流中</summary> /// <param name="stream">数据流</param> /// <param name="context">上下文</param> public override Boolean Write(Stream stream, Object context) { if (!base.Write(stream, context)) { return(false); } // 协议名 Write(stream, ProtocolName); // 协议等级 stream.Write(ProtocolLevel); // 连接标识 if (!WillTopicName.IsNullOrEmpty() || WillMessage != null) { HasWill = true; } if (!Username.IsNullOrEmpty()) { HasUsername = true; } if (!Password.IsNullOrEmpty()) { HasPassword = true; } var flag = 0; if (CleanSession) { flag |= 0b0000_0010; } if (HasWill) { flag |= 0b0000_0100; } flag |= ((Byte)WillQualityOfService << 3) & 0b0001_1000; if (WillRetain) { flag |= 0b0010_0000; } if (HasPassword) { flag |= 0b0100_0000; } if (HasUsername) { flag |= 0b1000_0000; } // 连接超时 stream.Write(KeepAliveInSeconds.GetBytes(false)); // 扩展 Write(stream, ClientId); if (HasWill) { Write(stream, WillTopicName); Write(stream, WillMessage); } if (HasUsername) { Write(stream, Username); } if (HasPassword) { Write(stream, Password); } return(true); }
public Credentials(Username username, SaltedHash passwordHashHash) { Username = username; PasswordHash = passwordHashHash; }
public async void LogIn() { IsLoggingIn = true; try { string username = Username.Trim(); string password = Password; if (UpdateType == UpdateTypes.NoDevice) { var resp = await PowerPlannerAuth.AddDeviceAsync( username : username, password : password); if (resp.Error != null) { SetError(resp.Error); return; } // Set their new device ID and token Account.DeviceId = resp.DeviceId; Account.LocalToken = resp.LocalToken; Account.Token = resp.Token; await AccountsManager.Save(Account); // Trigger a sync but don't await it try { var dontWait = SyncLayer.Sync.SyncAccountAsync(Account); } catch { } } else { var resp = await PowerPlannerAuth.CheckUpdatedCredentialsAsync( accountId : Account.AccountId, username : username, password : password); if (resp.Error != null) { SetError(resp.Error); return; } //update their local account Account.Username = username; Account.LocalToken = resp.LocalToken; Account.Token = resp.Token; await AccountsManager.Save(Account); // Trigger a sync but don't await it try { var dontWait = SyncLayer.Sync.SyncAccountAsync(Account); } catch { } } GoBack(); } catch { SetError("Failed to check your new credentials. Maybe you're offline?"); } finally { IsLoggingIn = false; } }
public void Update(Username username, Password password) { Username = username; Password = password; }
public async Task <bool> TrySignup(UserManagement.Data.UserManagementContext _context) { // verify all fields filled if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(FirstName) || string.IsNullOrEmpty(LastName)) { return(false); } Username = Username.ToLower(); Email = Email.ToLower(); // make sure not already in use if (_context.User.Count() > 0 && (_context.User.Any(u => u.Username == this.Username || u.Email == this.Email))) { return(false); } // verify questions foreach (var q in SecurityQuestions) { if (string.IsNullOrEmpty(q.Question)) { return(false); } q.QuestionID = _context.SecurityQuestion.Where(x => x.Question == q.Question).FirstOrDefault().QuestionID; } // verify answers for (int i = 0; i < SecurityAnswers.Count(); i++) { var a = SecurityAnswers[i]; a.QuestionID = SecurityQuestions[i].QuestionID; if (string.IsNullOrEmpty(a.Answer)) { return(false); } } // generate salt and password Hasher hasher = new Hasher(); string Salt = hasher.GenerateSalt(32); this.Password = hasher.HashPassword(this.Password, Salt, 100, 32); User NewUser; try { NewUser = new User { Username = this.Username , FirstName = this.FirstName , LastName = this.LastName , Email = this.Email , Salt = Salt , Password = this.Password }; } catch (Exception ex) { return(false); } // add user await _context.User.AddAsync( NewUser ); await _context.SaveChangesAsync(); // get id to assign answer int id = _context.User.FirstOrDefault(u => u.Username == NewUser.Username).UserID; if (id < 1) { return(false); } // assign answers foreach (SecurityAnswer a in SecurityAnswers) { await _context.SecurityAnswer.AddAsync( new SecurityAnswer { UserID = id //make matching easier , Answer = a.Answer.ToLower().Replace(" ", "").Replace("\t", "").Replace("\n", "") , QuestionID = a.QuestionID } ); } await _context.SaveChangesAsync(); // misuse password hasher to make an activation URL Salt = hasher.GenerateSalt(8); string url; do { int i = 0; url = hasher.HashPassword("a" + id + DateTime.UtcNow, "", 10 + i, 8 + (i / 8)); } while (_context.ServiceToken.Any(t => t.URL == url)); // make activation token ServiceToken newToken; try { newToken = new ServiceToken { UserID = id, Action = "activate", URL = url, Creation = DateTime.UtcNow, Expiration = DateTime.UtcNow.AddDays(365), Resolved = false }; } catch (Exception ex) { return(false); } await _context.ServiceToken.AddAsync(newToken); await _context.SaveChangesAsync(); return(true); }
public bool IsUsernameAvailable(Username username) { Contract.Requires(username != null); Account account = _accountRepository.FindAccount(username); return account == null; }
void ReleaseDesignerOutlets() { if (BackButton != null) { BackButton.Dispose(); BackButton = null; } if (BottomConstraint != null) { BottomConstraint.Dispose(); BottomConstraint = null; } if (DistanceText != null) { DistanceText.Dispose(); DistanceText = null; } if (EditSelf != null) { EditSelf.Dispose(); EditSelf = null; } if (EditSelfBack != null) { EditSelfBack.Dispose(); EditSelfBack = null; } if (EditSelfHeader != null) { EditSelfHeader.Dispose(); EditSelfHeader = null; } if (EditSpacer != null) { EditSpacer.Dispose(); EditSpacer = null; } if (HeaderBackground != null) { HeaderBackground.Dispose(); HeaderBackground = null; } if (HideButton != null) { HideButton.Dispose(); HideButton = null; } if (LastActiveDate != null) { LastActiveDate.Dispose(); LastActiveDate = null; } if (LikeButton != null) { LikeButton.Dispose(); LikeButton = null; } if (LocationTime != null) { LocationTime.Dispose(); LocationTime = null; } if (MapBottomSeparator != null) { MapBottomSeparator.Dispose(); MapBottomSeparator = null; } if (MapSatellite != null) { MapSatellite.Dispose(); MapSatellite = null; } if (MapStreet != null) { MapStreet.Dispose(); MapStreet = null; } if (MapTopSeparator != null) { MapTopSeparator.Dispose(); MapTopSeparator = null; } if (MenuBlock != null) { MenuBlock.Dispose(); MenuBlock = null; } if (MenuContainer != null) { MenuContainer.Dispose(); MenuContainer = null; } if (MenuIcon != null) { MenuIcon.Dispose(); MenuIcon = null; } if (MenuLayer != null) { MenuLayer.Dispose(); MenuLayer = null; } if (MenuReport != null) { MenuReport.Dispose(); MenuReport = null; } if (Name != null) { Name.Dispose(); Name = null; } if (NavigationSpacer != null) { NavigationSpacer.Dispose(); NavigationSpacer = null; } if (NextButton != null) { NextButton.Dispose(); NextButton = null; } if (PercentProgress != null) { PercentProgress.Dispose(); PercentProgress = null; } if (PreviousButton != null) { PreviousButton.Dispose(); PreviousButton = null; } if (ProfileImageContainer != null) { ProfileImageContainer.Dispose(); ProfileImageContainer = null; } if (ProfileImageScroll != null) { ProfileImageScroll.Dispose(); ProfileImageScroll = null; } if (ProfileViewDescription != null) { ProfileViewDescription.Dispose(); ProfileViewDescription = null; } if (ProfileViewMap != null) { ProfileViewMap.Dispose(); ProfileViewMap = null; } if (ProfileViewScroll != null) { ProfileViewScroll.Dispose(); ProfileViewScroll = null; } if (RegisterDate != null) { RegisterDate.Dispose(); RegisterDate = null; } if (ResponseRate != null) { ResponseRate.Dispose(); ResponseRate = null; } if (RippleImageNext != null) { RippleImageNext.Dispose(); RippleImageNext = null; } if (RippleImagePrev != null) { RippleImagePrev.Dispose(); RippleImagePrev = null; } if (RippleProfileView != null) { RippleProfileView.Dispose(); RippleProfileView = null; } if (RoundBottom != null) { RoundBottom.Dispose(); RoundBottom = null; } if (ScrollBottomConstraint != null) { ScrollBottomConstraint.Dispose(); ScrollBottomConstraint = null; } if (SendLocation != null) { SendLocation.Dispose(); SendLocation = null; } if (Snackbar != null) { Snackbar.Dispose(); Snackbar = null; } if (SnackBottomConstraint != null) { SnackBottomConstraint.Dispose(); SnackBottomConstraint = null; } if (SnackTopConstraint != null) { SnackTopConstraint.Dispose(); SnackTopConstraint = null; } if (Username != null) { Username.Dispose(); Username = null; } if (ViewportConstraint != null) { ViewportConstraint.Dispose(); ViewportConstraint = null; } }
internal void LoginSteps() { //Start the Login Global.Base.test = Global.Base.extent.StartTest("Property Owner Login"); //Populate in collection Global.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "LoginPage"); //Navigate to Url Global.GlobalDefinition.driver.Navigate().GoToUrl(Global.ExcelLib.ReadData(2, "Url")); Global.GlobalDefinition.wait(500); //Enter Username Username.SendKeys(Global.ExcelLib.ReadData(2, "UserName")); //Enter Password Password.SendKeys(Global.ExcelLib.ReadData(2, "Password")); Thread.Sleep(500); //Checking login button is displayed with assert try { Assert.IsTrue(LoginBtn.Displayed); } catch (Exception e) { Console.Write(e); } //Click on login Button LoginBtn.Click(); Thread.Sleep(1000); // Checking Page Title with assert try { string pageTitle = Global.GlobalDefinition.driver.Title; Assert.AreEqual("Properties | Property Community", "Properties | Property Community", pageTitle); //Assert.That(pageTitle,Does.Match("Dashboard")); } catch (Exception e) { Console.Write(e); } /* * //Verification * string message = Global.GlobalDefinition.driver.FindElement(By.XPath("//*[@id='main-content']/section/div[1]/h2")).Text; * string ActualMessage = Global.ExcelLib.ReadData(2, "LoginVerification"); * //Explicit Wait * Thread.Sleep(2000); * if (message == ActualMessage) * { * Global.Base.test.Log(LogStatus.Pass, "Property Owner Login Successfull"); * Global.SaveScreenShotClass.SaveScreenshot(Global.GlobalDefinition.driver, "Dashboard"); * } * else * { * Global.Base.test.Log(LogStatus.Fail, "Property Owner Login Unsuccessfull"); * } */ Global.GlobalDefinition.driver.Manage().Window.Maximize(); //Explicit Wait Thread.Sleep(1000); skipbtn.Click(); }
private static bool Equals(Username a, Username b) { return ((object)a == null && (object)b == null) || ((object)a != null && (object)b != null && a._username == b._username); }
public override string ToString() { return($"legacyProfileData: \n \t username: {Username.ToString()}, \n \t isMember: {IsMember.ToString()}, \n \t createdDate: {CreatedDate.ToString()}, \n \t migratedDate: {MigratedDate.ToString()}"); }
private void OnWebSocketMessage(object sender, MessageEventArgs e) { var messageJson = JObject.Parse(e.Data); var command = (string)messageJson["cmd"]; switch (command) { case "chat": var time = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc) .AddMilliseconds((double)messageJson["time"]); time = time.ToLocalTime(); var text = (string)messageJson["text"]; var nick = (string)messageJson["nick"]; var trip = (string)messageJson["trip"]; var richText = HackChatTextParser.GetRichText(text, this); var message = new Message(nick, trip, text, richText, text.ToLower().Contains(Username.ToLower()), time); OnMessage(message); break; case "onlineSet": OnlineUsers = messageJson["nicks"].ToObject <List <string> >(); OnInfo(InfoType.OnlineSet, OnlineUsers); break; case "onlineAdd": var addNick = (string)messageJson["nick"]; OnlineUsers.Add(addNick); OnInfo(InfoType.OnlineAdd, addNick); break; case "onlineRemove": var removeNick = (string)messageJson["nick"]; OnlineUsers.Remove(removeNick); OnInfo(InfoType.OnlineRemove, removeNick); break; case "warn": var warnText = (string)messageJson["text"]; switch (warnText) { case "Nickname must consist of up to 24 letters, numbers, and underscores": OnInfo(InfoType.InvalidUsername, warnText); break; case "Cannot impersonate the admin": OnInfo(InfoType.ImpersonatingAdmin, warnText); break; case "Nickname taken": OnInfo(InfoType.UsernameTaken, warnText); break; case "You are joining channels too fast. Wait a moment and try again.": OnInfo(InfoType.ChannelRatelimit, warnText); break; case "You are sending too much text. Wait a moment and try again.\n" + "Press the up arrow key to restore your last message.": OnInfo(InfoType.MessageRatelimit, warnText); break; default: Console.WriteLine("Unrecognised warning:\n" + e.Data); break; } break; default: Debug.WriteLine("Unrecognised message:"); Debug.WriteLine(e.Data); break; } }
public override int GetHashCode() { return(Account.GetHashCode() ^ Nickname.GetHashCode() ^ Username.GetHashCode() ^ Hostname.GetHashCode()); }
public override string GetPath() { return(Username.ToLowerInvariant()); }
public override int GetHashCode() { return((ConnectionId.GetHashCode() + Username.GetHashCode()) / 2 + Convert.ToInt32(IsKicked)); }