password reset
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
import React, { useState } from 'react'
|
||||
import React, { useState } from 'react';
|
||||
import toast, { Toaster } from 'react-hot-toast';
|
||||
import { Link, useParams } from 'react-router-dom';
|
||||
import { passwordReset } from '../services/PhpApi';
|
||||
import { passwordReset, getPwToken } from '../services/PhpApi';
|
||||
import useSWR from 'swr';
|
||||
import './InputForm.css';
|
||||
|
||||
export default function PasswordReset()
|
||||
@ -14,6 +15,11 @@ export default function PasswordReset()
|
||||
password2:''
|
||||
});
|
||||
|
||||
const { data, error, isLoading } = useSWR({'ptoken': passwordToken}, getPwToken);
|
||||
// data ist dogdata, logindata holt sich getProfilData.php aus $_SESSION
|
||||
if (error) return (<div>failed to load</div>);
|
||||
if (isLoading) return (<div>loading...</div>);
|
||||
|
||||
const onChangeInput = (e: React.FormEvent<HTMLInputElement> ) => {
|
||||
setFormData({
|
||||
...formData,
|
||||
|
||||
@ -239,7 +239,15 @@ export const logOut = () =>
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param form_data {
|
||||
password1: string,
|
||||
password2: string,
|
||||
passwordToken: string
|
||||
}
|
||||
* @returns
|
||||
*/
|
||||
export const passwordReset = async (form_data:
|
||||
FormData) =>
|
||||
{
|
||||
@ -256,6 +264,26 @@ export const passwordReset = async (form_data:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pwtoken object {'pwtoken': pwtoken }
|
||||
* @returns
|
||||
*/
|
||||
export const getPwToken = async (pwtoken: any) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
const {data} = await Axios.post('getPwToken.php', pwtoken);
|
||||
console.log('Api getPwToken');
|
||||
console.log(data);
|
||||
return data;
|
||||
}
|
||||
catch(err)
|
||||
{
|
||||
return {success:0, message:'getPwToken Server Error!'};
|
||||
}
|
||||
}
|
||||
|
||||
export const wantNewPw = async ({email}:{email: string}) =>
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user