public async Task <IHttpActionResult> PostForgot(JObject value) { var email = (string)value["email"]; if (!String.IsNullOrEmpty(email)) { var user = await OwinUserManager.FindByEmailAsync(email.Trim()); if (user != null) { if (await OwinUserManager.IsEmailConfirmedAsync(user.Id)) { // Send the link. var token = await OwinUserManager.GeneratePasswordResetTokenAsync(user.Id); var queryString = AccountUtils.GetMailLinkQueryString(token, user.Id); var host = Request.RequestUri.GetComponents(UriComponents.Host, UriFormat.Unescaped); var link = "https://" + host + "/account/reset-password?" + queryString; await EmailUtils.SendPasswordResetEmailAsync(email, link); } } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Handles succesful login callback /// </summary> /// <param name="sender"></param> /// <param name="e">Contains credentials</param> public void loginWindow_LoginSuccesful(object sender, LoginWindowEventArgs e) { Credentials = e.Credentials; LoggedAsLabel.Content += AccountUtils.LoginFromCredentials(Credentials); _gridViewPage = new Pages.MainPage(); Main.Content = _gridViewPage; }
/// <summary> /// Удаление счёта /// </summary> /// <param name="accountId">Уникальный идентификатор счёта</param> public ActionResult DeleteAccount(string accountId) { int id; if (!int.TryParse(accountId, out id)) { RedirectToAction("Accounts", new { message = string.Format("{0}. {1} {2}", Resource.ErrorMessageIdMustBeInteger, Resource.TextCurrentValue, accountId) }); } string message; var signalCount = accountRepository.GetSignalCount(id); if (signalCount == null) { message = Resource.ErrorMessageDataAccess; } else { message = signalCount > 0 ? string.Format("{0}: {1} - {2}. {3}: {4}", Resource.ErrorMessage, Resource.ErrorMessageCanNotDellAccount, Resource.MessageForRemovMustNotBeSignal, Resource.MessageSignalCountNow, signalCount) : AccountUtils.Delete(id); } return(Accounts(message)); }
public override Task OnConnected() { var userId = AccountUtils.GetUserId(Context.User.Identity); Groups.Add(Context.ConnectionId, KeyUtils.IntToKey(userId)); return(base.OnConnected()); }
public Account Validate(Account account) { if (account == null || string.IsNullOrEmpty(account.UserName) || string.IsNullOrEmpty(account.Password)) { return(null); } var query = $"SELECT * FROM Account WHERE LOWER(UserName) = '{account.UserName.ToLower()}'"; var data = _database.ExecuteToTable(query, null, Common.ExecuteTypeEnum.SqlQuery); if (data == null || data.Rows.Count <= 0) { return(null); } var tempAcc = SqlMapper <Account> .Map(data).FirstOrDefault(); if (!AccountUtils.VerifyPassword(tempAcc.Password, account.Password)) { return(null); } return(new Account { AccountId = tempAcc.AccountId, UserName = tempAcc.UserName, AccountType = tempAcc.AccountType, CreatedDate = tempAcc.CreatedDate }); }
public static void StorageAccountTestInit(TestContext testContext) { TestBase.TestClassInitialize(testContext); if (isResourceMode) { NodeJSAgent.AgentConfig.UseEnvVar = false; AzureEnvironment environment = Utility.GetTargetEnvironment(); managementClient = new ManagementClient(Utility.GetCertificateCloudCredential(), environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement)); accountUtils = new AccountUtils(lang, isResourceMode); accountName = accountUtils.GenerateAccountName(); resourceLocation = isMooncake ? Constants.MCLocation.ChinaEast : allowedLocation; resourceManager = new ResourceManagerWrapper(); resourceGroupName = accountUtils.GenerateResourceGroupName(); resourceManager.CreateResourceGroup(resourceGroupName, resourceLocation); var parameters = new SRPModel.StorageAccountCreateParameters(new SRPModel.Sku(SRPModel.SkuName.StandardGRS), SRPModel.Kind.StorageV2, isMooncake ? Constants.MCLocation.ChinaEast : allowedLocation); accountUtils.SRPStorageClient.StorageAccounts.CreateAsync(resourceGroupName, accountName, parameters, CancellationToken.None).Wait(); //resourceGroupName = "weitest"; //accountName = "weitesttemp"; } }
internal void UnregisterAccount(Message message, string text) { Bot = new TelegramBot(accessToken: ConfigurationManager.AppSettings[name: "accessKey"]); // set up regex sequence matcher var address = new Regex( pattern: @"[Nn]{1,1}[a-zA-Z0-9]{39,39}"); // extract any valid addresses var result = address.Matches(input: StringUtils.GetResultsWithoutHyphen(text)).Cast <Match>().Select(selector: m => m.Value).ToList(); var userNodes = NodeUtils.GetNodeByUser(chatId: message.Chat.Id); foreach (var acc in result) { SummaryUtils.DeleteHbSummaryForUser(account: acc, chatId: message.Chat.Id); SummaryUtils.DeleteTxSummaryForUser(account: acc, chatId: message.Chat.Id); } // delete any valid addresses AccountUtils.DeleteAccount(chatId: message.Chat.Id, accounts: result.Where(predicate: x => userNodes.All(predicate: y => y.IP != x)) .ToList()); // notify user var reqAction = new SendMessage(chatId: message.Chat.Id, text: result.Aggregate(seed: "Addresses unregistered: \n", func: (current, n) => current + StringUtils.GetResultsWithHyphen(n) + "\n")); Bot.MakeRequestAsync(request: reqAction); }
/// <summary> /// Contra Journal Entries /// </summary> /// <param name="env"></param> /// <param name="element"></param> /// <param name="tags"></param> /// <param name="from"></param> /// <param name="to"></param> /// <param name="value"></param> internal static void GenerateJournalEntries(PostingEngineEnvironment env, Transaction element, List <Tag> tags, string from, string to, double value) { var fromAccount = new AccountUtils().CreateAccount(AccountType.Find(from), tags, element); var toAccount = new AccountUtils().CreateAccount(AccountType.Find(to), tags, element); new AccountUtils().SaveAccountDetails(env, fromAccount); new AccountUtils().SaveAccountDetails(env, toAccount); var debitJournal = new Journal(element) { Account = fromAccount, When = env.ValueDate, StartPrice = 0, EndPrice = 0, CreditDebit = env.DebitOrCredit(fromAccount, value), Value = env.SignedValue(fromAccount, toAccount, true, value), FxRate = element.TradePrice, Event = Event.REALIZED_PNL, Fund = env.GetFund(element), }; var creditJournal = new Journal(debitJournal) { Account = toAccount, CreditDebit = env.DebitOrCredit(toAccount, value), Value = env.SignedValue(fromAccount, toAccount, false, value), }; env.Journals.AddRange(new[] { debitJournal, creditJournal }); }
public ActionResult Index() { List <Site> sites = new List <Site>(); sites = DbUtils.GetSitesActive(); if (sites.Count == 0) { throw new Exception("There was an error retreiving the sites list from the database"); } sites.Insert(0, new Site { ID = 0, Name = "Select a site", SiteID = "" }); ViewBag.Sites = new SelectList(sites, "ID", "Name"); nlogger.LogInfo("Admin Backdoor Index - user: "******"UserName", "UserName"); if (!SiteMapManager.SiteMaps.ContainsKey("adminbackdoor")) { SiteMapManager.SiteMaps.Register <XmlSiteMap>("adminbackdoor", sitmap => sitmap.LoadFrom("~/adminbackdoor.sitemap")); } return(View()); }
private static async void Notify(Account a, Transactions.TransactionData t) { try { var bot = new TelegramBot(accessToken: ConfigurationManager.AppSettings[name: "accessKey"]); var msg = "There is a new " + (t.transaction.type == 257 ? "" : "multisig ") + "transaction on account: \n" + StringUtils.GetResultsWithHyphen(a.EncodedAddress) + "\nhttp://explorer.ournem.com/#/s_account?account=" + a.EncodedAddress + "\nRecipient: \n" + (t.transaction.type == 257 ? StringUtils.GetResultsWithHyphen(t.transaction.recipient) : StringUtils.GetResultsWithHyphen(t.transaction.otherTrans.recipient)) + "\nAmount: " + (t.transaction.amount / 1000000) + " XEM"; var reqAction = new SendMessage(chatId: a.OwnedByUser, text: msg); Console.WriteLine(msg); await bot.MakeRequestAsync(request : reqAction); } catch (Exception e) { if (e.Message.Contains("blocked")) { AccountUtils.DeleteAccountsByUser(a.OwnedByUser); NodeUtils.DeleteUserNodes(a.OwnedByUser); UserUtils.DeleteUser(a.OwnedByUser); } } }
private void LoginRequest(int cnnId, int channelId, int recHostId, Net_LoginRequest msg) { string randomToken = AccountUtils.GenerateRandomString(256); Model_Account account = db.LoginAccount(msg.UsernameOrEmail, msg.Password, cnnId, randomToken); Net_LoginRequestResponse response = new Net_LoginRequestResponse(); if (account != null) { // login was successful response.success = 0; response.information = "Login was successful!"; response.connectionId = cnnId; response.token = randomToken; response.username = account.Username; response.discriminator = account.Discriminator; } else { // login was not successful response.success = 1; response.information = "Login attempt failed"; } SendClient(recHostId, cnnId, channelId, response); // let the client know if their login attempt was successful or not }
private void btnEnterPin_Click(object sender, EventArgs e) { if (isNextClicked) { return; } pinEntered = txtBxEnterPin.Text.Trim(); if (string.IsNullOrEmpty(pinEntered)) { return; } isNextClicked = true; if (!NetworkInterface.GetIsNetworkAvailable()) // if no network { progressBar.Opacity = 0; progressBar.IsEnabled = false; pinErrorTxt.Text = AppResources.Connectivity_Issue; pinErrorTxt.Visibility = System.Windows.Visibility.Visible; isNextClicked = false; return; } txtBxEnterPin.IsReadOnly = true; nextIconButton.IsEnabled = false; string unAuthMsisdn = (string)App.appSettings[App.MSISDN_SETTING]; pinErrorTxt.Visibility = System.Windows.Visibility.Collapsed; progressBar.Opacity = 1; progressBar.IsEnabled = true; AccountUtils.registerAccount(pinEntered, unAuthMsisdn, new AccountUtils.postResponseFunction(pinPostResponse_Callback)); }
public async Task UpdateDctorInfoTest() { String updateURL = BaseURL + "/doctor/profile/info"; String getDoctorURL = BaseURL + "/doctor/profile/doctor"; var newDoctor = CreateNewDoctor(); var client = await AccountUtils.LoginUserAndGetClient(doctor1, Password); var payload = HttpUtils.CreateContent(newDoctor); var response = await client.PostAsync(updateURL, payload); Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK); var response1 = await LoginDoctorAndGetDetails(getDoctorURL, doctor1); Assert.IsTrue(response1.Contains("Sectia 2")); newDoctor.Ward = "Sectia 1"; payload = HttpUtils.CreateContent(newDoctor); response = await client.PostAsync(updateURL, payload); Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK); response1 = await LoginDoctorAndGetDetails(getDoctorURL, doctor1); Assert.IsTrue(response1.Contains("Sectia 1")); }
internal async void RegisterAccounts(Message message) { Bot = new TelegramBot(accessToken: ConfigurationManager.AppSettings[name: "accessKey"]); if (UserUtils.GetUser(chatId: message.Chat.Id)?.UserName == null) { // add user based on their chat ID UserUtils.AddUser(userName: message.Chat.Username, chatId: message.Chat.Id); // declare message var msg1 = "You have been automatically registered, one moment please"; // send message notifying they have been registered var reqAction1 = new SendMessage(chatId: message.Chat.Id, text: msg1); // send message Bot.MakeRequestAsync(request: reqAction1); } // set up regex sequence to verify address validity var address = new Regex( pattern: @"[Nn]{1,1}[a-zA-Z0-9]{39,39}"); // extract any sequence matching addresses var result = address.Matches(input: StringUtils.GetResultsWithoutHyphen(message.Text)).Cast <Match>().Select(selector: m => m.Value).ToList(); // register any valid addresses for monitoring AccountUtils.AddAccount(chatId: message.Chat.Id, accounts: result); // notify user the account(s) was registered var reqAction = new SendMessage(chatId: message.Chat.Id, text: result.Aggregate(seed: "Addresses registered: \n", func: (current, n) => current + StringUtils.GetResultsWithHyphen(n) + "\n")); await Bot.MakeRequestAsync(request : reqAction); }
public async Task <IEnumerable <CreatableMachineDto> > Handle(GetCreatableMachinesForAccountQuery request, CancellationToken cancellationToken) { var account = await _context.Set <Account>() .Include(x => x.LicenseConfig) .Include(x => x.Sites) .FirstOrDefaultAsync(x => !x.IsDeleted && !x.IsTemplate && x.Id == request.Id, cancellationToken); if (account == null) { throw new EntityNotFoundException(nameof(Account), request.Id); } var machines = await _context.Set <Machine>().Where(x => x.AccountId == account.Id) .ToListAsync(cancellationToken); var licenseConfig = account.LicenseConfig; var sites = account.Sites; var creatableMachines = new List <CreatableMachineDto>(); var launcherMachine = machines.FirstOrDefault(x => x.IsLauncher); if (launcherMachine == null) { var site = licenseConfig.InstancePolicy == ServerInstancePolicy.AllInOne ? sites.FirstOrDefault() : null; creatableMachines.Add(new CreatableMachineDto() { IsLauncher = true, IsSiteMaster = licenseConfig.InstancePolicy == ServerInstancePolicy.AllInOne, Name = AccountUtils.GenerateMachineName(account.UrlFriendlyName, licenseConfig.InstancePolicy, "Launcher"), SiteId = site?.Id, SiteName = site?.UrlFriendlyName }); } if (licenseConfig.InstancePolicy == ServerInstancePolicy.InstancePerSiteMaster) { foreach (var site in sites) { var machine = machines.FirstOrDefault(x => x.SiteName == site.UrlFriendlyName); if (machine == null) { creatableMachines.Add(new CreatableMachineDto() { IsLauncher = false, IsSiteMaster = true, Name = AccountUtils.GenerateMachineName(account.UrlFriendlyName, licenseConfig.InstancePolicy, site.UrlFriendlyName), SiteId = site.Id, SiteName = site.UrlFriendlyName }); } } } return(creatableMachines); }
/// <summary> /// Dealing with the settlement event /// </summary> /// <param name="element"></param> /// <param name="debit"></param> /// <param name="credit"></param> /// <returns></returns> internal AccountToFrom GetFromToAccountOnSettlement(PostingEngineEnvironment env, Transaction element) { var accountTypes = AccountType.All; var listOfTags = new List <Tag> { Tag.Find("SecurityType"), Tag.Find("CustodianCode") }; if (_settledCash == null) { _settledCash = accountTypes.Where(i => i.Name.Equals("Settled Cash")).FirstOrDefault(); _pbUnsettledActivity = accountTypes.Where(i => i.Name.Equals("DUE FROM/(TO) PRIME BROKERS ( Unsettled Activity )")).FirstOrDefault(); } Account fromAccount = null; // Debiting Account Account toAccount = null; // Crediting Account switch (element.Side.ToLowerInvariant()) { case "buy": fromAccount = new AccountUtils() .CreateAccount(_pbUnsettledActivity, listOfTags, element); toAccount = new AccountUtils() .CreateAccount(_settledCash, listOfTags, element); break; case "sell": fromAccount = new AccountUtils() .CreateAccount(_pbUnsettledActivity, listOfTags, element); toAccount = new AccountUtils() .CreateAccount(_settledCash, listOfTags, element); break; case "short": fromAccount = new AccountUtils() .CreateAccount(_pbUnsettledActivity, listOfTags, element); toAccount = new AccountUtils() .CreateAccount(_settledCash, listOfTags, element); break; case "cover": fromAccount = new AccountUtils() .CreateAccount(_pbUnsettledActivity, listOfTags, element); toAccount = new AccountUtils() .CreateAccount(_settledCash, listOfTags, element); break; } new AccountUtils().SaveAccountDetails(env, fromAccount); new AccountUtils().SaveAccountDetails(env, toAccount); return(new AccountToFrom { From = fromAccount, To = toAccount }); }
/// <summary> /// Creates new account containing 0 money /// </summary> public void CreateNewAccount() { Accounts.Add(new Account { BankAccountNumber = AccountUtils.CreateAccountNumber(Constants.BankId, getLastAccountIndex().Result + 1), Amount = 0 }); }
private async Task <HttpResponseMessage> LoginClientAndPerformGet(String donorName, String URL) { var client = await AccountUtils.LoginUserAndGetClient(donorName, Password); var response = await client.GetAsync(URL); Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK); return(response); }
public Session StartNewSession(int accountId, int pin) { if (!AccountUtils.IsPincodeCorrect(accountId, pin)) { throw new InvalidPincodeException(); } return(_sessionManager.StartNewSession(accountId)); }
public void CreateAccountIdTest() { Assert.AreEqual(AccountUtils.CreateBankAccountNumberFromId(15), "0000000000000015"); Assert.AreEqual(AccountUtils.CreateBankAccountNumberFromId(150), "0000000000000150"); Assert.AreEqual(AccountUtils.CreateBankAccountNumberFromId(96), "0000000000000096"); Assert.AreEqual(AccountUtils.CreateBankAccountNumberFromId(1500), "0000000000001500"); Assert.AreEqual(AccountUtils.CreateBankAccountNumberFromId(1), "0000000000000001"); Assert.AreEqual(AccountUtils.CreateBankAccountNumberFromId(15), "0000000000000015"); }
private async Task <String> LoginDoctorAndGetDetails(String URL, String doctor) { var client = await AccountUtils.LoginUserAndGetClient(doctor, Password); var response = await client.GetAsync(URL); Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK); return(await response.Content.ReadAsStringAsync()); }
public ActionResult Create(string username, string password) { _accountRepository.CreateAccount(new Account { UserName = username, Password = AccountUtils.HashPassword(password) }); return(RedirectToAction("Index")); }
public void GeneratorAccountTest() { var account = AccountUtils.GeneratorAccount("adminUser" + new Random().Next(100000, 1000000).ToString()); var accountString = account.ToJson(); // Debug.WriteLine(accountString); _testOutput.WriteLine(accountString); Assert.True(accountString.ToObject <AccountDto>().PublicKey.Length > 0); }
public SystemStateMgr() { SetAudioOutputAsBuiltInSpeaker(); Account = new AccountUtils(); Account.AddUser(DefaultUserId, "Player"); Account.OpenUser(DefaultUserId); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); if (PhoneApplicationService.Current.State.ContainsKey("objectForFileTransfer")) { object[] fileTapped = (object[])PhoneApplicationService.Current.State["objectForFileTransfer"]; long messsageId = (long)fileTapped[0]; msisdn = (string)fileTapped[1]; string filePath = HikeConstants.FILES_BYTE_LOCATION + "/" + msisdn + "/" + Convert.ToString(messsageId); byte[] filebytes; MiscDBUtil.readFileFromIsolatedStorage(filePath, out filebytes); this.FileImage.Source = UI_Utils.Instance.createImageFromBytes(filebytes); } else if (PhoneApplicationService.Current.State.ContainsKey("displayProfilePic")) { string fileName; object[] profilePicTapped = (object[])PhoneApplicationService.Current.State["displayProfilePic"]; msisdn = (string)profilePicTapped[0]; string filePath = msisdn + HikeConstants.FULL_VIEW_IMAGE_PREFIX; //check if image is already stored byte[] fullViewBytes = MiscDBUtil.getThumbNailForMsisdn(filePath); if (fullViewBytes != null && fullViewBytes.Length > 0) { this.FileImage.Source = UI_Utils.Instance.createImageFromBytes(fullViewBytes); } else if (MiscDBUtil.hasCustomProfileImage(msisdn)) { fileName = msisdn + HikeConstants.FULL_VIEW_IMAGE_PREFIX; loadingProgress.Opacity = 1; if (!Utils.isGroupConversation(msisdn)) { AccountUtils.createGetRequest(AccountUtils.BASE + "/account/avatar/" + msisdn + "?fullsize=true", getProfilePic_Callback, true, fileName); } else { AccountUtils.createGetRequest(AccountUtils.BASE + "/group/" + msisdn + "/avatar?fullsize=true", getProfilePic_Callback, true, fileName); } } else { fileName = UI_Utils.Instance.getDefaultAvatarFileName(msisdn, Utils.isGroupConversation(msisdn)); byte[] defaultImageBytes = MiscDBUtil.getThumbNailForMsisdn(fileName); if (defaultImageBytes == null || defaultImageBytes.Length == 0) { loadingProgress.Opacity = 1; AccountUtils.createGetRequest(AccountUtils.AVATAR_BASE + "/static/avatars/" + fileName, getProfilePic_Callback, false, fileName); } else { this.FileImage.Source = UI_Utils.Instance.createImageFromBytes(defaultImageBytes); } } } }
private void deleteAccount_Click(object sender, EventArgs e) { MessageBoxResult result = MessageBox.Show("Are you sure about deleting account.", "Delete Account ?", MessageBoxButton.OKCancel); if (result == MessageBoxResult.Cancel) { return; } AccountUtils.deleteAccount(new AccountUtils.postResponseFunction(deleteAccountResponse_Callback)); }
private void callMe_Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (callMe.Opacity == 1) { string msisdn; App.appSettings.TryGetValue <string>(App.MSISDN_SETTING, out msisdn); AccountUtils.postForCallMe(msisdn, new AccountUtils.postResponseFunction(callMePostResponse_Callback)); MessageBox.Show(AppResources.EnterPin_CallingMsg_MsgBox); } }
/// <summary> /// Send the confirmation link in background /// </summary> /// <param name="email"></param> /// <param name="userId"></param> /// <param name="confirmationToken"></param> /// <param name="currentRequestUri">It is used to determine the server address (production/development) where the confirmation link should point</param> public async Task SendConfirmationEmail(string email, int userId, string displayName, string confirmationToken, Uri currentRequestUri) //public void SendConfirmationEmailInBackground(string email, int userId, string displayName, string confirmationToken, Uri currentRequestUri) { var queryString = AccountUtils.GetMailLinkQueryString(confirmationToken, userId); var host = currentRequestUri.GetComponents(UriComponents.Host, UriFormat.Unescaped); var link = "http://" + host + "/account/confirm-email?" + queryString; // TODO If the task fails, we will lose the message. The proper solution is to place the message into a reliable queue. //HostingEnvironment.QueueBackgroundWorkItem(ct => EmailUtils.SendConfirmationEmailAsync(email, displayName, link)); await EmailUtils.SendConfirmationEmailAsync(email, displayName, link); }
public SystemStateMgr() { Account = new AccountUtils(); Account.AddUser(DefaultUserId, "Player"); Account.OpenUser(DefaultUserId); // TODO: Let user specify. DesiredKeyboardLayout = (long)KeyboardLayout.Default; }
public SystemStateMgr() { SetAudioOutputAsBuiltInSpeaker(); Account = new AccountUtils(); UserId defaultUid = new UserId("00000000000000010000000000000000"); Account.AddUser(defaultUid, "Player"); Account.OpenUser(defaultUid); }