Merge pull request #637 from ente-io/post-ott
Use the new POST variant of /users/ott
This commit is contained in:
commit
5da3326dc2
|
@ -4,7 +4,7 @@ import * as Yup from 'yup';
|
|||
import constants from 'utils/strings/constants';
|
||||
import SubmitButton from 'components/SubmitButton';
|
||||
import router from 'next/router';
|
||||
import { changeEmail, getOTTForEmailChange } from 'services/userService';
|
||||
import { changeEmail, sendOTTForEmailChange } from 'services/userService';
|
||||
import { getData, LS_KEYS, setData } from 'utils/storage/localStorage';
|
||||
import { PAGES } from 'constants/pages';
|
||||
import { Alert, TextField } from '@mui/material';
|
||||
|
@ -32,7 +32,7 @@ function ChangeEmailForm() {
|
|||
) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
await getOTTForEmailChange(email);
|
||||
await sendOTTForEmailChange(email);
|
||||
setEmail(email);
|
||||
setShowOttInputVisibility(true);
|
||||
setShowMessage(true);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import constants from 'utils/strings/constants';
|
||||
import React, { useEffect } from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
import { getOtt } from 'services/userService';
|
||||
import { sendOtt } from 'services/userService';
|
||||
import { setData, LS_KEYS, getData } from 'utils/storage/localStorage';
|
||||
import { PAGES } from 'constants/pages';
|
||||
import FormPaperTitle from './Form/FormPaper/Title';
|
||||
|
@ -33,7 +33,7 @@ export default function Login(props: LoginProps) {
|
|||
setFieldError
|
||||
) => {
|
||||
try {
|
||||
await getOtt(email);
|
||||
await sendOtt(email);
|
||||
setData(LS_KEYS.USER, { email });
|
||||
router.push(PAGES.VERIFY);
|
||||
} catch (e) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
|||
import constants from 'utils/strings/constants';
|
||||
import { Formik, FormikHelpers } from 'formik';
|
||||
import * as Yup from 'yup';
|
||||
import { getOtt } from 'services/userService';
|
||||
import { sendOtt } from 'services/userService';
|
||||
import { setData, LS_KEYS } from 'utils/storage/localStorage';
|
||||
import { useRouter } from 'next/router';
|
||||
import SubmitButton from 'components/SubmitButton';
|
||||
|
@ -51,7 +51,7 @@ export default function SignUp(props: SignUpProps) {
|
|||
try {
|
||||
try {
|
||||
setData(LS_KEYS.USER, { email });
|
||||
await getOtt(email);
|
||||
await sendOtt(email);
|
||||
} catch (e) {
|
||||
setFieldError(
|
||||
'confirm',
|
||||
|
|
|
@ -4,7 +4,7 @@ import { LS_KEYS, getData, setData } from 'utils/storage/localStorage';
|
|||
import { useRouter } from 'next/router';
|
||||
import {
|
||||
verifyOtt,
|
||||
getOtt,
|
||||
sendOtt,
|
||||
logoutUser,
|
||||
clearFiles,
|
||||
putAttributes,
|
||||
|
@ -116,7 +116,7 @@ export default function Verify() {
|
|||
|
||||
const resendEmail = async () => {
|
||||
setResend(1);
|
||||
await getOtt(email);
|
||||
await sendOtt(email);
|
||||
setResend(2);
|
||||
setTimeout(() => setResend(0), 3000);
|
||||
};
|
||||
|
|
|
@ -26,8 +26,8 @@ const ENDPOINT = getEndpoint();
|
|||
|
||||
const HAS_SET_KEYS = 'hasSetKeys';
|
||||
|
||||
export const getOtt = (email: string) =>
|
||||
HTTPService.get(`${ENDPOINT}/users/ott`, {
|
||||
export const sendOtt = (email: string) =>
|
||||
HTTPService.post(`${ENDPOINT}/users/ott`, {
|
||||
email,
|
||||
client: 'web',
|
||||
});
|
||||
|
@ -265,11 +265,11 @@ export const _logout = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
export const getOTTForEmailChange = async (email: string) => {
|
||||
export const sendOTTForEmailChange = async (email: string) => {
|
||||
if (!getToken()) {
|
||||
return null;
|
||||
}
|
||||
await HTTPService.get(`${ENDPOINT}/users/ott`, {
|
||||
await HTTPService.post(`${ENDPOINT}/users/ott`, {
|
||||
email,
|
||||
client: 'web',
|
||||
purpose: 'change',
|
||||
|
|
Loading…
Reference in a new issue