Fakultas Ilmu Komputer UI

Commit 3b17148f authored by Ahmad Izzudin Alifyandra's avatar Ahmad Izzudin Alifyandra
Browse files

Merge branch 'forgot-password' into 'master'

Forgot Password Error Handling

See merge request !55
parents 9a815414 093aa5e5
import { useNavigation } from "@react-navigation/core";
import React from "react";
import { useState } from "react";
import { StyleSheet, View, Text } from "react-native";
import { StyleSheet, View, Text, Alert } from "react-native";
import Colors from "../../constants/Colors";
import { RootTabScreenProps } from "../../types/navigation";
import PlainForm from "../../components/Forms/PlainForm";
......@@ -10,6 +10,7 @@ import { MaterialIcons } from "@expo/vector-icons";
import MainButton from "../../components/button/MainButton";
import firebase from "firebase";
import { validateEmail } from "../../helpers/Validators";
import { forgotPassword } from "../../service/firebase/auth";
export default function InputForgotPassword({
navigation,
......@@ -46,10 +47,16 @@ export default function InputForgotPassword({
text={"Reset Password"}
colors={"Primary"}
onPress={() => {
if (validateEmail(email)) {
firebase.auth().sendPasswordResetEmail(email);
nav.navigate("Auth", { screen: "ForgotPasswordDone" });
}
forgotPassword(email)
.then(() =>
nav.navigate("Auth", { screen: "ForgotPasswordDone" })
)
.catch((e) =>
Alert.alert(
"Email tidak ditemukan",
"Silahkan masukkan email yang terdaftar"
)
);
}}
/>
</View>
......
......@@ -35,3 +35,7 @@ export const changePassword = async (password: string) => {
export const signUpAuth = async (email: string, password: string) => {
return await firebase.auth().createUserWithEmailAndPassword(email, password);
};
export const forgotPassword = async (email: string) => {
return await firebase.auth().sendPasswordResetEmail(email);
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment