0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

Added button to resend 2fa code

refs [ENG-1644](https://linear.app/tryghost/issue/ENG-1644/add-re-send-ui-flow)
This commit is contained in:
Michael Barrett 2024-10-10 16:11:54 +01:00 committed by Kevin Ansfield
parent 1f687ae466
commit 29d1026606
2 changed files with 29 additions and 0 deletions

View file

@ -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.';
}
}
}
}

View file

@ -41,6 +41,14 @@
data-test-button="verify" />
</form>
<GhTaskButton
@buttonText="Resend verification code"
@successText="Verification code sent"
@task={{this.resendTokenTask}}
@class="login gh-btn gh-btn-login gh-btn-block gh-btn-icon"
@type="submit"
data-test-button="resend" />
<p class="{{if this.flowErrors "main-error" "main-notification"}}" data-test-flow-notification>{{if this.flowErrors this.flowErrors this.flowNotification}}&nbsp;</p>
</section>
</div>