mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Added prompting for 2 factor auth setup after turning it on and saving.
This commit is contained in:
parent
c95849f468
commit
62b3af41c1
@ -337,6 +337,7 @@ namespace Teknik.Areas.Users.Controllers
|
||||
user.SecuritySettings.RecoveryVerified = false;
|
||||
}
|
||||
|
||||
bool oldTwoFactor = user.SecuritySettings.TwoFactorEnabled;
|
||||
user.SecuritySettings.TwoFactorEnabled = twoFactorEnabled;
|
||||
string newKey = string.Empty;
|
||||
if (twoFactorEnabled)
|
||||
@ -364,6 +365,11 @@ namespace Teknik.Areas.Users.Controllers
|
||||
string verifyUrl = Url.SubRouteUrl("user", "User.VerifyRecoveryEmail", new { Code = verifyCode });
|
||||
UserHelper.SendRecoveryEmailVerification(Config, user.Username, user.SecuritySettings.RecoveryEmail, resetUrl, verifyUrl);
|
||||
}
|
||||
|
||||
if (!oldTwoFactor && twoFactorEnabled)
|
||||
{
|
||||
return Json(new { result = new { checkAuth = true, key = newKey, qrUrl = Url.SubRouteUrl("user", "User.Action", new { action = "GenerateAuthQrCode", key = newKey }) } });
|
||||
}
|
||||
return Json(new { result = true });
|
||||
}
|
||||
return Json(new { error = "User does not exist" });
|
||||
|
@ -128,7 +128,17 @@
|
||||
success: function (html) {
|
||||
$.unblockUI();
|
||||
if (html.result) {
|
||||
window.location.reload();
|
||||
if (html.result.checkAuth)
|
||||
{
|
||||
$('#setupAuthenticatorLink').removeClass('hide');
|
||||
$('#authSetupSecretKey').text(html.result.key);
|
||||
$('#authQRCode').attr("src", html.result.qrUrl);
|
||||
$('#authenticatorSetup').modal('show');
|
||||
}
|
||||
else
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
else {
|
||||
var error = html;
|
||||
|
@ -29,8 +29,6 @@
|
||||
<div id="authSetupStatus"></div>
|
||||
</div>
|
||||
</div>
|
||||
@if (Model.SecuritySettings.TwoFactorEnabled)
|
||||
{
|
||||
<form class="form" action="##" method="post" id="confirmAuthSetup">
|
||||
<p>To get a third party app working, either scan the QR code below or type the secret key into the app.</p>
|
||||
<div class="row">
|
||||
@ -38,7 +36,7 @@
|
||||
<p class="text-muted">QR Code:</p>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<img src="@Url.SubRouteUrl("user", "User.Action", new { action = "GenerateAuthQrCode", key = Model.SecuritySettings.TwoFactorKey })" width="200" height="200" alt="qr code" />
|
||||
<img id="authQRCode" src="@Url.SubRouteUrl("user", "User.Action", new { action = "GenerateAuthQrCode", key = Model.SecuritySettings.TwoFactorKey })" width="200" height="200" alt="qr code" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -64,7 +62,6 @@
|
||||
<button class="btn btn-primary" id="auth_setup_confirm" type="button" name="auth_setup_confirm">Confirm</button>
|
||||
</div>
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -136,12 +133,9 @@
|
||||
<input id="update_security_two_factor" name="update_security_two_factor" title="whether the key should be saved on the server or not" type="checkbox" value="true" @(Model.SecuritySettings.TwoFactorEnabled ? "checked" : string.Empty) />
|
||||
</label>
|
||||
</div>
|
||||
@if (Model.SecuritySettings.TwoFactorEnabled)
|
||||
{
|
||||
<p class="form-control-static">
|
||||
<small><a href="#" class="text-primary" id="SetupAuthenticator" data-toggle="modal" data-target="#authenticatorSetup"><i class="fa fa-lock"></i> Set Up Authenticator</a></small>
|
||||
</p>
|
||||
}
|
||||
<p class="form-control-static @(Model.SecuritySettings.TwoFactorEnabled ? string.Empty : "hide")" id="setupAuthenticatorLink">
|
||||
<small><a href="#" class="text-primary" id="SetupAuthenticator" data-toggle="modal" data-target="#authenticatorSetup"><i class="fa fa-lock"></i> Set Up Authenticator</a></small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
Loading…
Reference in New Issue
Block a user