Docs
Methods
MethodsLogin Method | Fire Snippets Docs

Login Method

Handles user login by attaching an onclick event listener to a specified button.

login(snippetId)

Description

Handles user login by attaching an onclick event listener to a specified button. When the button is clicked, it authenticates the user using Firebase Auth.

Method Signature

login(snippetId)

Parameters

  • snippetId: (string) The ID of the login snippet configuration.

Returns

  • Promise: Resolves with a userCredential object upon successful login, or rejects with an error.

Usage Example

// Initialize FireSnippets
const fireSnippets = new FireSnippets('your-api-key');
 
// Call the login method
fireSnippets.login('your-login-snippet-id')
  .then(userCredential => {
    // User logged in successfully
    console.log('User logged in:', userCredential);
  })
  .catch(error => {
    // Handle login errors
    console.error('Login error:', error);
  });

HTML Elements Required

Ensure your HTML includes the following elements with IDs matching those specified in your snippet configuration:

<input type="email" id="email-input" placeholder="Email">
<input type="password" id="password-input" placeholder="Password">
<button id="login-button">Login</button>

Was this helpful?
Docs
Copyright © Fire Snippets. All rights reserved.