Passwort reset

This commit is contained in:
2023-02-09 11:11:53 +01:00
parent 0c5cfcbd19
commit 2a02c79370
5 changed files with 186 additions and 13 deletions

View File

@ -1,30 +1,34 @@
import React, { useState } from 'react'
import toast, { Toaster } from 'react-hot-toast';
import './ImportForm.css';
import {wantNewPw} from '../services/PhpApi'
import './InputForm.css';
function WantNewPw()
{
const [email, setEmail] = useState('');
const onChangeInput = (e: React.FormEvent<HTMLInputElement> ) => {
const onChangeInput = (e: React.FormEvent<HTMLInputElement> ) =>
{
// console.log(e.currentTarget.value);
setEmail(e.currentTarget.value);
}
const submitForm = async (e: React.FormEvent<HTMLFormElement>) =>
{
e.preventDefault();
if(e.currentTarget.value.trim() !== '')
{
toast.error('Bitte Feld ausfüllen!');
return;
}
// console.log(email);
// console.log((e.currentTarget.elements[0] as HTMLInputElement).value);
// if((e.currentTarget.elements[0] as HTMLInputElement).value.trim() === '')
// {
// toast.error('Bitte Feld ausfüllen!');
// return;
// }
const data = await wantNewPw(email);
const data = await wantNewPw({email: email});
if(data.success)
{
toast.success('Erfolgreich Passwort geändert!');
e.currentTarget.reset();
toast.success('Passwort angefordert! Bitte Postfach ' + email + ' checken!');
//e.currentTarget.reset();
}
else if(!data.success && data.message)
{

View File

@ -267,7 +267,7 @@ export const wantNewPw = async ({email}:{email: string}) =>
}
catch(err)
{
return {success:0, message:'Password Reset Server Error!'};
return {success:0, message:'Password Request Server Error!'};
}
}