public string Execute(IList <string> parameters) { var username = parameters[0]; var password = parameters[1]; var firstName = parameters[2]; var lastName = parameters[3]; var newUser = new User(); newUser.Username = username; newUser.Password = password; newUser.FirstName = firstName; newUser.LastName = lastName; newUser.Authorization = Authorization.NormalUser; var account = AccountCreator.CreateAccount(newUser); newUser.Account = account; this.dbContext.Users.Add(newUser); dbContext.SaveChanges(); this.authProvider.CurrentUsername = newUser.Username; return($"{newUser.Username} has successfully registered! You are now logged in.\n100 have been added to your account.\n Type a command or 'help logged user' for help to see your options."); }
public StatusCodeResult AddNewUser([FromBody] UserInfoDTO data) { //TODO: use factory to create object instance AccountCreator c = new AccountCreator(); //TODO: probably a lot more checks we could add to make data we get can actually go in DB // return 400 if anything was an empty string if (data.userID.Equals("") || data.firstName.Equals("") || data.lastName.Equals("") || data.email.Equals("") || data.password.Equals("") || data.password2.Equals("")) { return(StatusCode(400)); } // if account gets stored in db successfully if (c.storeNewAccount(data.userID, data.firstName, data.lastName, data.email, data.password)) { // check that both passwords are the same if (data.password.Equals(data.password2) && data.password.Length > 7) { return(StatusCode(200)); } else { return(StatusCode(400)); } } else { return(StatusCode(400)); } }
private static void on_is_account_linked(IntPtr creator, int status, string resp) { AccountCreator thiz = fromNativePtr <AccountCreator>(creator); AccountCreatorListener listener = thiz.Listener; listener.on_is_account_linked_public?.Invoke(thiz, (AccountCreatorStatus)status, resp); }
public VanillaWorld(int portNumber, int maxConnections) { DBC = new DBCLibrary(); WorldDatabase = new DatabaseUnitOfWork <WorldDatabase>(); CharacterDatabase = new DatabaseUnitOfWork <CharacterDatabase>(); Server = new WorldServer(this); Components.Add(new ActionButtonComponent(this)); Components.Add(new AuthComponent(this)); Components.Add(new CharacterComponent(this)); Components.Add(new ChatMessageComponent(this)); Components.Add(new WeatherComponent(this)); Components.Add(new EntityComponent(this)); Components.Add(new GameObjectComponent(this)); Components.Add(new LoginComponent(this)); Components.Add(new LogoutComponent(this)); Components.Add(new MailComponent(this)); Components.Add(new MiscComponent(this)); Components.Add(new PlayerMovementComponent(this)); Components.Add(new SpellComponent(this)); ChatCommands = new ChatCommandParser(); Server.Start(portNumber, maxConnections); var accountCreator = new AccountCreator(); accountCreator.CreateAccount("andrew", "password"); accountCreator.CreateAccount("lucas", "password"); }
void _initProperty() { AccountCreator accountCreator_ = __singleton <AccountCreator> ._instance(); accountCreator_._registerCreate( new PropertyId <MoneyMgr>()); }
/// <summary> /// Create new account. /// </summary> /// <param name="accountType">type of account</param> /// <param name="name">name of owner</param> /// <param name="surname">surname of owner</param> /// <param name="amount">start amount of money</param> public void CreateNewAccount(string accountType, string name, string surname, double amount = 0) { Account account = AccountCreator.CreateAccount(accountType, GenerateId.Generate(), name, surname, amount); AccountRepository.Create(account.ToDalAccount()); UnitOfWork.Commit(); CurrentAccount = account; }
public AccountCreatorServiceTests() { _testEncryptionUtility = new EncryptionUtility(); var testAccountOptions = new DbContextOptionsBuilder <AccountDbContext>() .UseInMemoryDatabase("TestAccountCreatorDatabase") .Options; var testAccountDbContext = new AccountDbContext(testAccountOptions); _testAccountQueries = new AccountQueries(testAccountDbContext); _testAccountCreator = new AccountCreator(_testEncryptionUtility, _testAccountQueries); }
public void Test_CreateAccount(Type t, AccountCreator.AccountType type, string id, string name, string surname, double amout, int points) { Account account = AccountCreator.CreateAccount(type, id, name, surname, amout, points); Assert.That(account.GetType, Is.EqualTo(t)); Assert.That(account.Name, Is.EqualTo(name)); Assert.That(account.Id, Is.EqualTo(id)); Assert.That(account.Surname, Is.EqualTo(surname)); Assert.That(account.Amount, Is.EqualTo(amout)); Assert.That(account.Points, Is.EqualTo(points)); }
private void CreateButton_OnClick(object sender, RoutedEventArgs e) { double weight = double.Parse(WeightTextBox.Text); double age = double.Parse(AgeTextBox.Text); if (!AccountCreator.CreateAccount(NameTextBox.Text, UserNameTextBox.Text, "123456", weight, age)) { DialogBox.Show("User Exists", "The user already exists", "Okay"); } Utilities.LoginContentView.Header = "login"; Utilities.LoginContentView.Content = new LoginContent(); }
public void ThenCreatingAnotherAccountWithTheSameEmailAddressResultsInAnError() { var accountCreator = new AccountCreator(AccountRepository, AccountPasswordRepository, TimeWarpUserStateRepository, AuthenticationManager); var accountController = new AccountController(accountCreator); var exception = Assert.Throws <HttpResponseException>(() => accountController.Post(_request, TestHelper.NameMock, TestHelper.EmailAddressMock)); Assert.AreEqual(HttpStatusCode.BadRequest, exception.Response.StatusCode); }
public AccountTestBase() { AccountRepository = new MockAccountsRepository(); AccountPasswordRepository = new MockAccountPasswordRepository(); TimeWarpUserStateRepository = new MockUserStateRepository(); AuthenticationManager = new MockTimeWarpAuthenticationManager(); FakeTimeCalculatorFactory.GetTimeWarpStateCalculator(); var accountCreator = new AccountCreator(AccountRepository, AccountPasswordRepository, TimeWarpUserStateRepository, AuthenticationManager); AccountController = new AccountController(accountCreator); }
Account _loginAccount(AccountLoginB nAccountLoginB, uint nDeviceType) { Account result_ = null; uint accountId = nAccountLoginB._getAccountId(); if (mAccounts.ContainsKey(accountId)) { result_ = mAccounts[accountId]; } if (null == result_) { result_ = nAccountLoginB._createAccount(); result_._addDeviceType(nDeviceType); result_._setAccountMgr(this); AccountCreator accountCreator_ = __singleton <AccountCreator> ._instance(); accountCreator_._runCreate(result_); result_.m_tRunLogin(); mAccounts[accountId] = result_; } return(result_); }
public StatusCodeResult ChangePassword([FromBody] UserInfoDTO data) { string email = ""; // get users email from the token sent email = SessionController.sm.getEmail(data.authToken); // make sure user is authenticated if (SessionController.sm.ifTokenValid(data.authToken)) { AccountCreator c = new AccountCreator(); // check that passwords match and length is 8 or more if (data.password.Equals(data.password2) && data.password.Length > 7) { // check that old password was correct int status = AccountValidator.compareCredentials(email, data.currentPassword); // if current password was valid, go through with password change if (status == 1) { c.changePassword(data.password, email); return(StatusCode(200)); } else { return(StatusCode(400)); } } else { return(StatusCode(400)); } } else { return(StatusCode(401)); } }
public AccountController(AccountCreator accountCreator, TransactionHandler transactionHandler) { _accountCreator = accountCreator; _transactionHandler = transactionHandler; }
public void Setup() { MockDataKeeper = new Mock <IDataAccessKeeper>(); AccountCreator = new AccountCreator(MockDataKeeper.Object); }
static void Main(string[] args) { //instantiate dependencies of AccountCreatorService and LoginService var encryptionUtility = new EncryptionUtility(); var accountOptions = new DbContextOptionsBuilder <AccountDbContext>() .UseInMemoryDatabase("BankingAppDatabase") .Options; var accountDbContext = new AccountDbContext(accountOptions); var accountQueries = new AccountQueries(accountDbContext); var accountId = 1; while (true) { Console.WriteLine("Welcome to Taylor Bank. Please choose from the following menu options:"); Console.WriteLine("a) Create new account"); Console.WriteLine("b) Login"); Console.WriteLine("c) Quit"); var menuChoice = Console.ReadLine(); switch (menuChoice) { case "a": var accountCreator = new AccountCreator(encryptionUtility, accountQueries); accountCreator.NewAccountId = accountId; var accountCreated = false; var creationAttempts = 0; //used as a flag to limit failed attempts so users don't get stuck in an endless loop while (!accountCreated) { var newUsername = GetUserInput("Username:"******"Password:"******"Re-enter password:"******"Exiting after 5 failed account creation attempts.\n"); break; } accountId++; break; case "b": var loggedIn = false; var loginAttempts = 0; var loggedInAccountId = -1; var loginService = new LoginService(encryptionUtility, accountQueries); while (!loggedIn) { var username = GetUserInput("Username:"******"Password:"******"Exiting after 5 failed login attempts.\n"); break; } //loggedInAccountId always equals -1 unless the account credentials have been successfully validated if (loggedInAccountId != -1) { LoggedInMenuOptions(loggedInAccountId, ref loggedIn); } break; case "c": Quit(); break; default: Console.WriteLine("Invalid selection, please choose again.\n"); break; } } }