Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
342 views
in Technique[技术] by (71.8m points)

firebase password reset react native

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...