Header Ads

Python Django with Google Firebase - Firebase Authentication : SignUp form Using Pyrebase #Part3

In this part of Python Django with Google Firebase tutorial we'll extend Firebase Authentication and explore how we can create user SignUp Form and maintain each user data in database with additional functionality of Invalid  SignUp alert (existing user, invalid email/ password format).




Check out this video, code below follows the video to help
If you like videos like this consider donating $1, or simply turn off AdBlocker. Either helps me to continue making tutorials.


Transcript / Cheat Sheet :


Templates:
First we need to edit our 'SignIn.html' template in which we will add a button for SignUp which will be redirected to 'SignUp.html', 

SignIn.html

{% if messg %}
<script>
alert('{{ messg }}');
</script>
{% endif %}
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sign</title>
</head>
<body>
<form action="/postsign/" method="post">
{% csrf_token %}
Email :
<input type="email" name="email"><br><br>
Password:
<input type="password" name="pass"><br><br>
<input type="submit" value="SignIn">
<button type="button" onclick="location.href='{% url 'signup' %}'">SignUp</button>
</form>
</body>
</html>
A simple Signup form for creating user account, using POST operation sends user info to views.py which creates user account using pyrebase library, here if condition is added for getting invalid SignUp alert.

{% if messg %}
<script>
alert('{{ messg }}');
</script>
{% endif %}
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sign</title>
</head>
<body>
<form action="/postsignup/" method="post">
{% csrf_token %}
Name:
<input type="text" name="name"><br><br>
Email :
<input type="email" name="email"><br><br>
Password:
<input type="password" name="pass"><br><br>
<input type="submit" value="SignUp">
</form>
</body>
</html>

2 comments:

  1. Hello, I got an OPERATION_NOT_ALLOWED from firebase with create_user_with_email_and_password(email,passw). Any idea to fix this issue? I think it could be related with the csrf token maybe. Thanks!

    ReplyDelete
  2. Is it possible to authenticate using GoogleAuthProvider and FacebookAuthProvide?

    ReplyDelete

Powered by Blogger.