Issue
I would appreciate help!
Everything works (user SignUp success also in DB) except that it somehow doesnt print my Test at the end altough there shouln't be an exception? That means my welcome.html is not being rendered.
signUp Page
<div class="signup-container">
<h1>What's up Austria</h1>
<a> Create an account</a>
<form action="/postsignup/" method="post">
{% csrf_token %}
<input type="name" name="name" placeholder="Name" required />
<input type="email" name="email" placeholder="E-Mail" required />
<input type="password" name="pass" placeholder="Password" required />
<button type="submit" value="SignUp ">Sign Up</button>
</form>
<a onclick="location.href='/signin/'" class="login-link"
>Already have an account? Sign in</a
>
</div>
My postSignUp view:
authe comes from firebase up in the code
firebase=pyrebase.initialize_app(config)
authe = firebase.auth()
database = firebase.database()
def postSignUp(request):
name = request.POST.get('name')
email = request.POST.get('email')
passw = request.POST.get('pass')
try:
user=authe.create_user_with_email_and_password(email,passw)
uid = user['localId']
idtoken = request.session['uid']
#data = {"name":name, "status":"1"}
#database.child("users").child(uid).child("details").set(data)
except:
return render(request, "signUp.html")
print("Test")
return render(request, "welcome.html", {"e":email})
I am expecting that the print("Test") is being executed and the return render(request, "welcome.html", {"e":email}) rendered.
I am still landing on the SignUp but the user was created in the DB.
Solution
I have tested it again with changing the except to see what the error acutally is
def postSignUp(request):
name = request.POST.get('name')
email = request.POST.get('email')
passw = request.POST.get('pass')
try:
user=authe.create_user_with_email_and_password(email,passw)
uid = user['localId']
idtoken = request.session['uid']
#data = {"name":name, "status":"1"}
#database.child("users").child(uid).child("details").set(data)
except BaseException as e:
print(e)
#return render(request, "signUp.html")
print("Test")
return render(request, "welcome.html", {"e":email})
error printed:
"code": 400,
"message": "WEAK_PASSWORD : Password should be at least 6 characters",
"errors": [
{
"message": "WEAK_PASSWORD : Password should be at least 6 characters",
"domain": "global",
"reason": "invalid"
After I did use a 6 characters password it did not execute the except. Hope this helps future readers.
Answered By - Thomas Leitner
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.