Password resets
This commit is contained in:
		@ -45,3 +45,38 @@ export function val(api) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export function forgot(api) {
 | 
			
		||||
    let form = document.getElementById("forgot-form");
 | 
			
		||||
 | 
			
		||||
    if (form.checkValidity() === false) {
 | 
			
		||||
        // this.event.preventDefault();
 | 
			
		||||
        // this.event.stopPropagation();
 | 
			
		||||
        form.classList.add("was-validated");
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    form.classList.add("was-validated");
 | 
			
		||||
 | 
			
		||||
    let payload = {
 | 
			
		||||
        email: document.getElementById("email").value,
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    const requestOptions = {
 | 
			
		||||
        method: 'post',
 | 
			
		||||
        headers: {
 | 
			
		||||
            'Accept': 'application/json',
 | 
			
		||||
            'Content-Type': 'application/json',
 | 
			
		||||
        },
 | 
			
		||||
        body: JSON.stringify(payload),
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    fetch(api + "/api/forgot-password", requestOptions)
 | 
			
		||||
        .then(response => response.json())
 | 
			
		||||
        .then(response => {
 | 
			
		||||
            console.log(response)
 | 
			
		||||
            if (response.error === false) {
 | 
			
		||||
                showSuccess("forgot-messages", "Password reset email sent")
 | 
			
		||||
            } else {
 | 
			
		||||
                showError("forgot-messages", response.message)
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user