Formatting code

This commit is contained in:
rockstardev
2020-02-28 23:15:14 -06:00
parent a303e793b4
commit 56380a5fb3

View File

@@ -39,7 +39,7 @@ namespace BTCPayServer.Controllers
SettingsRepository _SettingsRepository; SettingsRepository _SettingsRepository;
Configuration.BTCPayServerOptions _Options; Configuration.BTCPayServerOptions _Options;
private readonly BTCPayServerEnvironment _btcPayServerEnvironment; private readonly BTCPayServerEnvironment _btcPayServerEnvironment;
public U2FService _u2FService; public U2FService _u2FService;
ILogger _logger; ILogger _logger;
public AccountController( public AccountController(
@@ -75,7 +75,7 @@ namespace BTCPayServer.Controllers
[AllowAnonymous] [AllowAnonymous]
public async Task<IActionResult> Login(string returnUrl = null) public async Task<IActionResult> Login(string returnUrl = null)
{ {
if (User.Identity.IsAuthenticated && string.IsNullOrEmpty(returnUrl)) if (User.Identity.IsAuthenticated && string.IsNullOrEmpty(returnUrl))
return RedirectToLocal(); return RedirectToLocal();
// Clear the existing external cookie to ensure a clean login process // Clear the existing external cookie to ensure a clean login process
@@ -85,7 +85,7 @@ namespace BTCPayServer.Controllers
{ {
SetInsecureFlags(); SetInsecureFlags();
} }
ViewData["ReturnUrl"] = returnUrl; ViewData["ReturnUrl"] = returnUrl;
return View(); return View();
} }
@@ -126,7 +126,7 @@ namespace BTCPayServer.Controllers
if (await _userManager.CheckPasswordAsync(user, model.Password)) if (await _userManager.CheckPasswordAsync(user, model.Password))
{ {
LoginWith2faViewModel twoFModel = null; LoginWith2faViewModel twoFModel = null;
if (user.TwoFactorEnabled) if (user.TwoFactorEnabled)
{ {
// we need to do an actual sign in attempt so that 2fa can function in next step // we need to do an actual sign in attempt so that 2fa can function in next step
@@ -145,14 +145,14 @@ namespace BTCPayServer.Controllers
} }
else else
{ {
var incrementAccessFailedResult = await _userManager.AccessFailedAsync(user); var incrementAccessFailedResult = await _userManager.AccessFailedAsync(user);
ModelState.AddModelError(string.Empty, "Invalid login attempt."); ModelState.AddModelError(string.Empty, "Invalid login attempt.");
return View(model); return View(model);
} }
} }
var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: true); var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: true);
if (result.Succeeded) if (result.Succeeded)
{ {
@@ -215,7 +215,7 @@ namespace BTCPayServer.Controllers
{ {
return RedirectToAction("Login"); return RedirectToAction("Login");
} }
ViewData["ReturnUrl"] = returnUrl; ViewData["ReturnUrl"] = returnUrl;
var user = await _userManager.FindByIdAsync(viewModel.UserId); var user = await _userManager.FindByIdAsync(viewModel.UserId);
@@ -276,7 +276,7 @@ namespace BTCPayServer.Controllers
return View("SecondaryLogin", new SecondaryLoginViewModel() return View("SecondaryLogin", new SecondaryLoginViewModel()
{ {
LoginWith2FaViewModel = new LoginWith2faViewModel { RememberMe = rememberMe }, LoginWith2FaViewModel = new LoginWith2faViewModel { RememberMe = rememberMe },
LoginWithU2FViewModel = (await _u2FService.HasDevices(user.Id))? await BuildU2FViewModel(rememberMe, user): null LoginWithU2FViewModel = (await _u2FService.HasDevices(user.Id)) ? await BuildU2FViewModel(rememberMe, user) : null
}); });
} }
@@ -322,7 +322,7 @@ namespace BTCPayServer.Controllers
return View("SecondaryLogin", new SecondaryLoginViewModel() return View("SecondaryLogin", new SecondaryLoginViewModel()
{ {
LoginWith2FaViewModel = model, LoginWith2FaViewModel = model,
LoginWithU2FViewModel = (await _u2FService.HasDevices(user.Id))? await BuildU2FViewModel(rememberMe, user): null LoginWithU2FViewModel = (await _u2FService.HasDevices(user.Id)) ? await BuildU2FViewModel(rememberMe, user) : null
}); });
} }
} }
@@ -463,7 +463,7 @@ namespace BTCPayServer.Controllers
_EmailSenderFactory.GetEmailSender().SendEmailConfirmation(model.Email, callbackUrl); _EmailSenderFactory.GetEmailSender().SendEmailConfirmation(model.Email, callbackUrl);
if (!policies.RequiresConfirmedEmail) if (!policies.RequiresConfirmedEmail)
{ {
if(logon) if (logon)
await _signInManager.SignInAsync(user, isPersistent: false); await _signInManager.SignInAsync(user, isPersistent: false);
return RedirectToLocal(returnUrl); return RedirectToLocal(returnUrl);
} }
@@ -536,7 +536,7 @@ namespace BTCPayServer.Controllers
var callbackUrl = Url.ResetPasswordCallbackLink(user.Id, code, Request.Scheme); var callbackUrl = Url.ResetPasswordCallbackLink(user.Id, code, Request.Scheme);
_EmailSenderFactory.GetEmailSender().SendEmail(model.Email, "Reset Password", _EmailSenderFactory.GetEmailSender().SendEmail(model.Email, "Reset Password",
$"Please reset your password by clicking here: <a href='{callbackUrl}'>link</a>"); $"Please reset your password by clicking here: <a href='{callbackUrl}'>link</a>");
return RedirectToAction(nameof(ForgotPasswordConfirmation)); return RedirectToAction(nameof(ForgotPasswordConfirmation));
} }
@@ -622,8 +622,8 @@ namespace BTCPayServer.Controllers
return RedirectToAction(nameof(HomeController.Index), "Home"); return RedirectToAction(nameof(HomeController.Index), "Home");
} }
} }
private bool CanLoginOrRegister() private bool CanLoginOrRegister()
{ {
return _btcPayServerEnvironment.IsDevelopping || _btcPayServerEnvironment.IsSecure; return _btcPayServerEnvironment.IsDevelopping || _btcPayServerEnvironment.IsSecure;
@@ -636,7 +636,7 @@ namespace BTCPayServer.Controllers
Severity = StatusMessageModel.StatusSeverity.Error, Severity = StatusMessageModel.StatusSeverity.Error,
Message = "You cannot login over an insecure connection. Please use HTTPS or Tor." Message = "You cannot login over an insecure connection. Please use HTTPS or Tor."
}); });
ViewData["disabled"] = true; ViewData["disabled"] = true;
} }