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:
parent
1f687ae466
commit
29d1026606
2 changed files with 29 additions and 0 deletions
|
@ -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.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}} </p>
|
||||
</section>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue