import React from 'react';
import { StyleSheet, Text, View, Image, Dimensions, TextInput, Button, StatusBar} from 'react-native';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
import Button2 from '../shared/button_2'
export default class ChangePassword extends React.Component{
state = {
name: "",
email: "",
};
forgotPassword = (email) => {
firebase.auth().sendPasswordResetEmail(email)
.then(function (user) {
alert('Please check your email...')
}).catch(function (e) {
console.log(e)
})
}
render() {
return (
<KeyboardAwareScrollView>
<View>
<StatusBar backgroundColor="grey" barStyle="dark-content"/>
<View style={styles.image_view}>
<Image
source={require("../assets/images/dcuhublogo_higherres.png")}
resizeMode="contain"
resizeMode="center"
style={styles.image_style}>
</Image>
</View>
<View style={styles.placeholder_style}>
<TextInput
style={styles.placeholder_text}
// SECURE PASSWORD ie hides the texts
placeholder="Email address"/>
</View>
{/* THIS ALSO USES FIREBASE AUTHENTICATION
ONCE PASSWORD IS CHANGED/UPDATE, IT SHOULD TAKE THE USER TO THE
LOGIN SCREEN AGAIN */}
<View>
<Button2 text='Reset password' onPress={(forgotPassword) => this.props.navigation.navigate('Login')}/>
</View>
</View>
</KeyboardAwareScrollView>
);
}
}
const styles = StyleSheet.create({
placeholder_style: {
flexDirection:"row",
alignItems:"center",
marginHorizontal:40,
borderWidth:2,
marginTop:15,
paddingHorizontal:10,
borderColor:"#25afcd",
borderRadius:23,
paddingVertical:7 // size of the placeholder
},
top_placeholder: {
flexDirection:"row",
alignItems:"center",
marginHorizontal:40,
borderWidth:2,
marginTop: -50,
paddingHorizontal:10,
borderColor:"#25afcd",
borderRadius:23,
paddingVertical: 7
},
placeholder_text: {
paddingHorizontal:10
},
image_style: {
width: Dimensions.get('screen').width,
height: Dimensions.get('screen').height / 2
},
image_view: {
alignSelf: 'center',
justifyContent: 'center'
}
})
im running the above to get a password reset email for an email thats stored in my firebase auth, why doesn't this work, where am I going wrong? The buttons and everything work properly its just the forgotpassword, with the docs and everything online I'm doing it exactly how its supposed to be done best to my knowledge. Am i missing something?
I'm new to using firebase.
question from:
https://stackoverflow.com/questions/65896375/firebase-password-reset-react-native 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…