public IActionResult ShowRecoveryCodes() { LoggerController.AddBeginMethodLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name); s.Restart(); var recoveryCodes = (string[])TempData[RecoveryCodesKey]; if (recoveryCodes == null) { s.Stop(); LoggerController.AddEndMethodLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, s.ElapsedMilliseconds); return(RedirectToAction(nameof(TwoFactorAuthentication))); } var model = new ShowRecoveryCodesViewModel { RecoveryCodes = recoveryCodes }; s.Stop(); LoggerController.AddEndMethodLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, s.ElapsedMilliseconds); return(View(model)); }
public async Task <IActionResult> Disable2fa() { LoggerController.AddBeginMethodLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name); s.Restart(); var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var disable2faResult = await _userManager.SetTwoFactorEnabledAsync(user, false); if (!disable2faResult.Succeeded) { throw new ApplicationException($"Unexpected error occured disabling 2FA for user with ID '{user.Id}'."); } _logger.LogInformation("User with ID {UserId} has disabled 2fa.", user.Id); s.Stop(); LoggerController.AddEndMethodLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, s.ElapsedMilliseconds); return(RedirectToAction(nameof(TwoFactorAuthentication))); }
public async Task <IActionResult> ConfirmEmail(string userId, string code) { LoggerController.AddBeginMethodLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name); s.Restart(); if (userId == null || code == null) { s.Stop(); LoggerController.AddEndMethodLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, s.ElapsedMilliseconds); return(RedirectToAction(nameof(HomeController.Index), "Home")); } var user = await _userManager.FindByIdAsync(userId); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{userId}'."); } var result = await _userManager.ConfirmEmailAsync(user, code); s.Stop(); LoggerController.AddEndMethodLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, s.ElapsedMilliseconds); return(View(result.Succeeded ? "ConfirmEmail" : "Error")); }
public async Task <IActionResult> TwoFactorAuthentication() { LoggerController.AddBeginMethodLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name); s.Restart(); var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var model = new TwoFactorAuthenticationViewModel { HasAuthenticator = await _userManager.GetAuthenticatorKeyAsync(user) != null, Is2faEnabled = user.TwoFactorEnabled, RecoveryCodesLeft = await _userManager.CountRecoveryCodesAsync(user), }; s.Stop(); LoggerController.AddEndMethodLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, s.ElapsedMilliseconds); return(View(model)); }
public Engine(ILogger logger, IInputReader inputReader, IOutputWriter outputWriter) { this.logger = logger; this.outputWriter = outputWriter; this.loggerController = new LoggerController(inputReader, outputWriter); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { LoggerController.AddBeginMethodLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name); s.Restart(); ValidationResult retval = new ValidationResult(""); IPasswordModel rvm = (IPasswordModel)validationContext.ObjectInstance; int nonLetterAndDigit = 0; int digit = 0; int upperCase = 0; int lowerCase = 0; string password = string.Empty; if (rvm.Password == null) { password = rvm.NewPassword; } else { password = rvm.Password; } foreach (char c in password) { if (char.IsDigit(c)) { digit++; } else if (!char.IsLetterOrDigit(c)) { nonLetterAndDigit++; } else if (char.IsUpper(c)) { upperCase++; } else if (char.IsLower(c)) { lowerCase++; } } if (nonLetterAndDigit == 0) { retval.ErrorMessage += "Hasło powinno zawierać przynajmniej jeden znak niealfanumeryczny."; } if (digit == 0) { retval.ErrorMessage += "Hasło powinno zawierać przynajmniej jedną cyfrę."; } if (upperCase == 0) { retval.ErrorMessage += "Hasło powinno zawierać przynajmniej jedną dużą literę."; } if (lowerCase == 0) { retval.ErrorMessage += "Hasło powinno zawierać przynajmniej jedną małą literę."; } s.Stop(); LoggerController.AddEndMethodLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, s.ElapsedMilliseconds); return(string.IsNullOrEmpty(retval.ErrorMessage) ? ValidationResult.Success : retval); }
public void Start() { experimentController = GameObject.Find("GameManager").GetComponent <LoggerController>(); // fetch the trial logger to save data to CSV }
private void RenderDashboardForChosenRole(Roles role) { List <string> options = new List <string>(); int response; string header = ""; if (role == Roles.Admin) { header = $"Hello {this.person.FirstName} {this.person.LastName}. Your Branch Location is {(person as BankAdmin).BranchLocation}"; options.Add("Make Transaction"); options.Add("View Transactions"); options.Add("Update Transactions"); options.Add("Delete Transactions"); options.Add("View Logs"); options.Add("Logout"); } else if (role == Roles.User) { header = $"Hello {person.FirstName} {person.LastName}. Your account type is {(person as BankUser).AccountType}"; options.Add("Make Transaction"); options.Add("View Transactions"); options.Add("Logout"); } Menu m = new Menu(options.ToArray()); bool goodResponse = false; do { response = m.RenderMenu(header); switch (response) { case -1: case 6: LogEntry l = new LogEntry("Logout", DateTime.Now); this._router.Navigate(Routes.Splash); l.AddEndTime(DateTime.Now); LoggerController.AddToLog(l.ToString()); LogEntry.SetActor("User", Roles.Unauthenticated); Helpers.FreeAndNil(ref l); goodResponse = true; break; case 1: this._router.Navigate(Routes.MakeTransaction, this.person); goodResponse = true; break; case 2: this._router.Navigate(Routes.ViewTransaction, this.person); goodResponse = true; break; case 3: if (role == Roles.User) { this._router.Navigate(Routes.Splash); goodResponse = true; } else if (role == Roles.Admin) { this._router.Navigate(Routes.UpdateTransaction, this.person); goodResponse = true; } break; case 4: if (role == Roles.User) { Console.WriteLine("Bad choice! Try again..."); Console.ReadKey(); Console.Clear(); goodResponse = false; } else if (role == Roles.Admin) { this._router.Navigate(Routes.DeleteTransaction, this.person); goodResponse = true; } break; case 5: if (role == Roles.User) { Console.WriteLine("Bad choice! Try again..."); Console.ReadKey(); Console.Clear(); goodResponse = false; } else if (role == Roles.Admin) { this._router.Navigate(Routes.ViewLogs, this.person); goodResponse = true; } break; default: Console.WriteLine("Bad choice! Try again..."); Console.ReadKey(); Console.Clear(); goodResponse = false; break; } } while (!goodResponse); }
// Use this for initialization void Start() { experimentController = GameObject.Find("GameManager").GetComponent <TrialLogger>(); experimentLogger = GameObject.Find("GameManager").GetComponent <LoggerController>(); }
public LoggerControllerTest() { _manager = new Mock <ILoggerManager>(MockBehavior.Strict); _controller = new LoggerController(_manager.Object); }
public static void WritePhysioLog(string line) { LoggerController.WriteLine(LoggerController.Type.PhysioData, line); }
// METHODS public static void WriteEventLog(string line) { LoggerController.WriteLine(LoggerController.Type.Events, line); }
public void Setup() { controller = new LoggerController(new Mocks.MockLoggerWebService()); }