Browse Source

added destroyOTPSession, so that one can remove OTP account

develop
Andrew Woodlee 2 years ago
parent
commit
4ac56f1315
  1. 5
      app/services/otp-auth.js
  2. 12
      app/views/admin/otp/index.pug
  3. 5
      app/views/otp/new-account.pug

5
app/services/otp-auth.js

@ -217,6 +217,11 @@ class OtpAuthService extends SiteService {
return true; return true;
} }
async destroyOtpSession (req, serviceName) {
delete req.session.otp[serviceName];
await this.saveSession(req)
}
async removeForUser (user) { async removeForUser (user) {
return await OtpAccount.deleteMany({ user: user }); return await OtpAccount.deleteMany({ user: user });
} }

12
app/views/admin/otp/index.pug

@ -5,13 +5,17 @@ block content
div(uk-grid).uk-flex-middle div(uk-grid).uk-flex-middle
.uk-width-expand .uk-width-expand
h1.margin-remove Tokens h1.margin-remove Tokens
.uk-width-auto section.uk-section.uk-section-default.uk-section-xsmall
.uk-container
.uk-text-small
h4 This is where you will regenerate OTP tokens for your admin account and destroy your old OTP account.
//- .uk-width-auto
button( button(
type="button", type="button",
data-user= user, data-user= user._id,
onclick="return dtp.adminApp.generateOTPTokens(event);", onclick="return dtp.adminApp.generateOTPTokens(event);",
).uk-button.dtp-button-danger ).uk-button.dtp-button-danger
+renderButtonIcon('fa-repeat', 'Generate OTP Tokens') +renderButtonIcon('fa-repeat', 'Generate OTP Tokens')
//- regenerate route should set this so tokens can be viewed once. //- regenerate route should set this so tokens can be viewed once.
if otpRegen if otpRegen
section.uk-section.uk-section-default.uk-section-xsmall section.uk-section.uk-section-default.uk-section-xsmall
@ -21,4 +25,4 @@ block content
each token of tokens each token of tokens
ul.uk-list.uk-list-divider ul.uk-list.uk-list-divider
li li
.uk-text-small= token.token .uk-text-small= token.token

5
app/views/otp/new-account.pug

@ -17,5 +17,6 @@ block content
section.uk-section.uk-section-default.uk-section-xsmall section.uk-section.uk-section-default.uk-section-xsmall
.uk-container .uk-container
p Your account is now enabled with access to #{site.name} #{otpServiceName}. p Your account is now enabled with access to #{site.name} #{otpAccount.service}.
a(href= otpRedirectURL, title="Continue").uk-button.uk-button-primary.uk-border-pill Continue a(href= otpRedirectURL, title="Continue").uk-button.uk-button-primary.uk-border-pill Continue

Loading…
Cancel
Save