Save authentication data to Firebase Realtime Database

Viewed 21

I need the username and password that is created to be saved in the database, I have already created my database with realtime database that I am currently using to store data from a form that I create

    import 'package:firebase_auth/firebase_auth.dart';
    import 'dart:async';
    import 'package:firebase_database/firebase_database.dart';

    abstract class BaseAuth {
    Future<String> singInWithEmailAndPassword(String email, String password);
    Future<String> createUserWithEmailAndPassword(String email, String password);
    Future<String> currentUser();
    Future<void> singOut();
    }

    class Auth implements BaseAuth {
    final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
    final databaseRef = FirebaseDatabase.instance.ref();

    @override
    Future<String> singInWithEmailAndPassword(
    String email, String password) async {
    UserCredential user = await _firebaseAuth.signInWithEmailAndPassword(
    email: email.toString(), password: password.toString());
    return user.toString();
    }

    @override
    Future<String> createUserWithEmailAndPassword(
    String email, String password) async {
    UserCredential user = await _firebaseAuth.createUserWithEmailAndPassword(
    email: email.toString(), password: password.toString());
    return user.toString();
    }

     @override
    Future<String> currentUser() async {
     User currentUser = _firebaseAuth.currentUser!;
     return currentUser.toString();
      }

      @override
     Future<void> singOut() async {
     return _firebaseAuth.signOut();
    }
     }

This es my auth.dart,this is where i created my methods to create and login

I hope you can support me since this is part of my final project

0 Answers
Related