Building a fresh User profile with Firebase and Vue

Hey there! I'm currently in the process of developing a user system using Vue and Firebase. I've successfully included the necessary Firebase script in my project along with some code. However, I'm running into an issue where clicking on the submit button fails to create a user in Firebase. Your assistance would be greatly appreciated! :) Thanks for your help! <3

  <div class="signin">
   <div class="card" style="width: 18rem;">
        <img class="card-img-top" src="https://upload.wikimedia.org/wikipedia/commons/f/f2/Kingsman_the_golden_circle_logo.png" alt="Card image cap">
        <div class="card-body">
            <h5 class="card-title">SignIn</h5>
              <b-form @submit="onSubmit" @reset="onReset" v-if="show">
                <!-- Email  -->
                <b-form-group id="input-group-email" label="Email address:" label-for="input-email">
                  <b-form-input id="input-email" v-model="email" type="email" placeholder="Enter email"></b-form-input>
                </b-form-group>
                <!-- Password  -->
                <b-form-group id="input-group-pass" label="Password:" label-for="input-pass">
                  <b-form-input id="input-pass" type="password" aria-describedby="password-help-block"></b-form-input>
                   <b-form-text id="password-help-block">
                     Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
                   </b-form-text>
                </b-form-group>
                <b-button type="submit" variant="primary">Submit</b-button>
              </b-form>
        </div>
    </div>
  </div>
</template> 

<script>
import firebase from 'firebase'

export default {
  name: 'SignIn',
  props: {
    msg: String
  },
  data () {
    return {
      form: {
        email: '',
        password: ''
      },
      show: true
    }
  },
  methods: {
    onSubmit (evt) {
      evt.preventDefault()
      firebase.auth().createUserWithEmailAndPassword(this.email, this.password).then(
        (user) => {
          this.$router.replace('home')
        },
        (err) => {
          alert('Oops.' + err.message)
        }
      )
    },
    onReset (evt) {
      this.form.email = ''
      this.form.password = ''

      this.show = false
      this.$nextTick(() => {
        this.show = true
      })
    }
  }
}
</script>

Answer №1

When setting up your template, you include:

<b-form-input ... v-model="email" ...></b-form-input>

In the method section, you have:

firebase.auth().createUserWithEmailAndPassword(this.email, ....
 

However, in your data declaration, data is structured as follows:

  data () {
    return {
      form: {   //  <=== see the form here, that is not taken into account in the above parts of your code
        email: '',  
        password: ''
      },
      show: true
    }
  },

Another observation is the absence of v-model="password" (or

v-model="form.password"
).


To ensure consistency, align your code elements within the component.

One way to correct this inconsistency is by adjusting the data structure as follows:

  data () {
    return {
      email: '',
      password: '',
      show: true
    }
  },

Alternatively, consider modifying the code like this:

firebase.auth().createUserWithEmailAndPassword(this.form.email, this.form.password).then(...)

I recommend using vue-devtools for debugging these basic issues...

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to connect to a Node server from outside the network if the application is only listening on 'localhost'?

When utilizing the Express framework and we implement app.listen(port), the app will be located at localhost:port/ On a local machine, it is clear how to access this address using a local browser running on the same machine. Even clients within the same n ...

Display class name in React only when the variable is set to true

import React from 'react'; import logo from './logo.svg'; import './App.css'; function App() { return ( <div className="App"> <h1 className={ isTrue ? 'primary' : ''}>{ fa ...

Error retrieving user by provider account ID using Google and Firebase adapter with Next Auth

Encountering an issue while trying to integrate Google Provider with Firebase Adapter in Next Auth. Upon selecting an account, the following error is displayed: Running Firebase 9 TypeError: client.collection is not a function at getUserByProvider ...

Tips for updating the default color of a switch label in vuetify

I have been exploring the official documentation of Vuetify and noticed that the labels for switches come with predefined colors. Is there a way to customize these colors and set them to black? The switch is being passed as a prop from a global component c ...

Incorporating Hyperlinks into Text using React I18next

I'm facing an issue with I18next. I can't seem to make links to websites work correctly using the following code: import React, { Suspense } from "react"; import i18n from "i18next"; import { initReactI18next, useTranslation, ...

Changing the color of a menu item in Bootstrap when a modal window is closed: A guide

I am implementing Twitter Bootstrap and attempting to launch a modal popup by clicking on a menu item. Below is the code snippet: <div class="navbar navbar-fixed-bottom"> <div class="navbar-inner"> <ul class="nav pull-right"> ...

Is it necessary to sanitize strings before assigning them as the content of a textarea element?

Consider the situation described below: var evil_string = "..."; $('#mytextarea').val(evil_string); Is it necessary to sanitize an untrusted string before setting it as the value of a textarea element? While I am aware of the importance of han ...

Arranging and Refining Custom Header for Vuetify 2: A Comprehensive Guide

I'm struggling with incorporating default filter and sort capabilities into a Vuetify table while using a custom header design for the first time. Here is the HTML code I am working with: <v-data-table :headers="headers" :items=" ...

Tips for shutting down an HTML webpage with the help of JavaScript

Recently, I've been working on a project to implement a feature that automatically closes the website when an incorrect password is entered. However, I am fairly new to JavaScript and still in the early stages of learning. Below is the code snippet I ...

Which is better for decorating logo text - CSS3 or Jquery?

I've been attempting to achieve this design using CSS without much success. The goal is for the entire logo to scale using fittext.js while looking visually appealing. However, I keep encountering obstacles that prevent me from achieving my desired re ...

Why won't my AngularJS checkbox stay checked?

In my application, I have the following code: <input type="checkbox" ng-checked="vm.eduToEdit.test" /> {{vm.eduToEdit.test}} <input type="checkbox" ng-model="vm.eduToEdit.test"> The value of vm.eduToEdit.test is displaying t ...

What is the best way to retrieve the offsetHeight of a Component Element using Vue.js?

I am currently working on a Vue.js component and successfully inserting it into the DOM. My goal is to find out its rendered height once it's in the DOM, specifically its offsetHeight. However, I seem to be missing something obvious as I can't fi ...

limitation in bootstrap ensures that only one collapse element is open at any

Hey, can someone help me fix this code? I'm trying to make it so that only one element opens at a time, but I can't seem to figure out how. Right now, if I click on two elements, they both open and the other one doesn't close. This is what ...

Is there a way to identify the subdocument ids that have been updated in Mongoose when performing an

Is there a reliable way to retrieve the _id of subdocuments that are inserted into an array within my document using doc.updateOne? I am concerned about getting incorrect _id values when multiple updates occur. This is my current approach, but I'm wo ...

Connecting subscribe functions in Meteor React Native

I've been working on a react native app using meteor and the library react-native-meteor. I've run into an issue where I need to make a series of calls one after the other, such as signing in, subscribing to data, and so on. In my actual code, i ...

Tips for displaying an asp.net form using javascript functions

I am currently developing a login page in asp.net and have utilized a template from CodePen at http://codepen.io/andytran/pen/PwoQgO It is my understanding that an asp.net page can only have one form tag with runat="server". However, I need to incorporate ...

Steps for incorporating code to calculate the total price and append it to the orderMessage

I am seeking help with this program that my professor assigned to me. The instructions marked by "//" are the ones I need to implement in the code, but I'm struggling to understand how to proceed. Any assistance would be greatly appreciated, even just ...

Looping through Vue with multiple options

Looking for help with Vue2 looping to display multiple options within a select element. We have an object structured like this; sorting = { name: [ 'asc', 'desc' ], price: [ 'cheapest', ...

The response from the $http.get request indicates an HTTP status code of

I am currently experimenting with angularJS to interface with an API I developed. The root route of the API is set up to display information about the API in JSON format: { "Company": "Test Company", "Version": "0.1" } When I use jquery's $. ...

Developing a dynamic table using HTML and JavaScript

I have a question that might sound silly, but I am trying to retrieve the HTML content from this particular website using JavaScript. The data I'm interested in is located at the center of the page within a dynamic table which does not change the URL ...