From 29d1026606ed41a83d4d7bd1db436c026c911581 Mon Sep 17 00:00:00 2001 From: Michael Barrett Date: Thu, 10 Oct 2024 16:11:54 +0100 Subject: [PATCH] Added button to resend 2fa code refs [ENG-1644](https://linear.app/tryghost/issue/ENG-1644/add-re-send-ui-flow) --- ghost/admin/app/controllers/signin-verify.js | 21 ++++++++++++++++++++ ghost/admin/app/templates/signin-verify.hbs | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/ghost/admin/app/controllers/signin-verify.js b/ghost/admin/app/controllers/signin-verify.js index e38ed85263..f67b78388c 100644 --- a/ghost/admin/app/controllers/signin-verify.js +++ b/ghost/admin/app/controllers/signin-verify.js @@ -30,6 +30,7 @@ class VerifyData { export default class SigninVerifyController extends Controller { @service ajax; @service session; + @service ghostPaths; @tracked flowErrors = ''; @tracked verifyData = new VerifyData(); @@ -62,4 +63,24 @@ export default class SigninVerifyController extends Controller { } } } + + @task + *resendTokenTask() { + const resendTokenPath = `${this.ghostPaths.apiRoot}/session/verify`; + + try { + yield this.ajax.post(resendTokenPath, { + contentType: 'application/json;charset=utf-8', + // ember-ajax will try and parse the response as JSON if not explicitly set + dataType: 'text' + }); + return true; + } catch (error) { + if (error && error.payload && error.payload.errors) { + this.flowErrors = error.payload.errors[0].message; + } else { + this.flowErrors = 'There was a problem resending the verification token.'; + } + } + } } diff --git a/ghost/admin/app/templates/signin-verify.hbs b/ghost/admin/app/templates/signin-verify.hbs index a7ecfa450e..4e2ac364ca 100644 --- a/ghost/admin/app/templates/signin-verify.hbs +++ b/ghost/admin/app/templates/signin-verify.hbs @@ -41,6 +41,14 @@ data-test-button="verify" /> + +

{{if this.flowErrors this.flowErrors this.flowNotification}}