|
1 | | -import {postRawRequest} from '../base_actions' |
| 1 | +import {postRawRequest, postRawRequestFull } from '../base_actions' |
2 | 2 |
|
3 | 3 | export const verifyAccount = (email, token) => { |
4 | 4 |
|
@@ -27,3 +27,40 @@ export const resendVerificationEmail = (email, token) => { |
27 | 27 |
|
28 | 28 | return postRawRequest(window.RESEND_VERIFICATION_EMAIL_ENDPOINT)(params, {'X-CSRF-TOKEN': token}); |
29 | 29 | } |
| 30 | + |
| 31 | +// verify / recovery complete login via a server-side redirect, so use the *Full helper to |
| 32 | +// recover the final URL for top-window navigation. |
| 33 | +export const verify2FA = (otpValue, method, trustDevice, token) => { |
| 34 | + const params = { |
| 35 | + otp_value: otpValue, |
| 36 | + method: method, |
| 37 | + trust_device: trustDevice ? 1 : 0 |
| 38 | + }; |
| 39 | + |
| 40 | + return postRawRequestFull(window.VERIFY_2FA_ENDPOINT)(params, {'X-CSRF-TOKEN': token}); |
| 41 | +} |
| 42 | + |
| 43 | +export const resend2FA = (method, token) => { |
| 44 | + const params = { |
| 45 | + method: method |
| 46 | + }; |
| 47 | + |
| 48 | + return postRawRequestFull(window.RESEND_2FA_ENDPOINT)(params, {'X-CSRF-TOKEN': token}); |
| 49 | +} |
| 50 | + |
| 51 | +export const verifyRecoveryCode = (recoveryCode, token) => { |
| 52 | + const params = { |
| 53 | + recovery_code: recoveryCode |
| 54 | + }; |
| 55 | + |
| 56 | + return postRawRequestFull(window.RECOVERY_2FA_ENDPOINT)(params, {'X-CSRF-TOKEN': token}); |
| 57 | +} |
| 58 | + |
| 59 | +export const authenticateWithPassword = (formData, token) => { |
| 60 | + const params = Object.fromEntries(formData.entries()); |
| 61 | + return postRawRequestFull(window.FORM_ACTION_ENDPOINT)(params, {'X-CSRF-TOKEN': token}); |
| 62 | +} |
| 63 | + |
| 64 | +export const cancelLogin = (token) => { |
| 65 | + return postRawRequest(window.CANCEL_LOGIN_ENDPOINT)({}, {'X-CSRF-TOKEN': token}); |
| 66 | +} |
0 commit comments