@kenny9/refine-firebase

1.0.2 • Public • Published

Refine framework Firebase Authentication Provider

This repository contains an implementation of a Firebase Authentication Provider for a React application using the Refine framework.

Features

  • User login with email and password
  • User registration with email, password, and display name
  • Password reset functionality
  • Persistent login sessions
  • User profile updates
  • Email verification after registration

Installation

  1. Install the dependencies:

    npm i @kenny9/refine-firebase
    
  2. Set up your Firebase project:

    • Go to the Firebase Console.
    • Create a new project or use an existing one.
    • Go to the Project Settings and add a new web app.
    • Copy the Firebase configuration and replace the placeholder in firebaseConfig.ts.
  3. Configure Firebase Authentication:

    • Enable Email/Password authentication in the Firebase Console under Authentication > Sign-in method.

Usage

  1. Import the FirebaseAuth class and set up your authentication provider:

    import { FirebaseAuth } from "./firebaseauth";
    import { authProvider } from "./authProvider";
    
    const firebaseAuth = new FirebaseAuth();
    const authProvider = firebaseAuth.getAuthProvider();
  2. Use the authentication provider in your application:

    import { Refine } from "@refinedev/core";
    import { authProvider } from "./authProvider";
    
    function App() {
      return (
        <Refine authProvider={authProvider}>
          {/* Your app components */}
        </Refine>
      );
    }

FirebaseAuth Class

The FirebaseAuth class provides methods to handle various authentication tasks:

  • handleLogIn: Logs in a user with email and password.
  • handleRegister: Registers a new user with email, password, and optional display name.
  • handleLogOut: Logs out the current user.
  • handleResetPassword: Sends a password reset email.
  • handleUpdatePassword: Updates the current user's password.
  • handleForgotPassword: Sends a password reset email.
  • getUserIdentity: Returns the current user's email and display name.
  • handleCheckAuth: Checks if a user is authenticated.
  • getPermissions: Returns the user's permissions.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Package Sidebar

Install

npm i @kenny9/refine-firebase

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

20.3 kB

Total Files

7

Last publish

Collaborators

  • kenny9