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