Closed Sanchitkedia closed 6 months ago
I am getting the exact same issue
I checked the 03 branch here on github as well, it looks like my code in the course is the same as on the 03 branch, but I get the test error
Yes, I tested the 03 Branch as well and encountered the same problem.
Can I take a look at the code you have in the register
method of your AuthDAO
?
I have the code from the tutorial dropdown that says "Click here to reveal the fully-implemented register() method"
this is my code, I get the same error:
def register(self, email, plain_password, name):
encrypted = bcrypt.hashpw(plain_password.encode("utf8"), bcrypt.gensalt()).decode('utf8')
def create_user(tx, email, encrypted, name):
return tx.run(""" // (1)
CREATE (u:User {
userId: randomUuid(),
email: $email,
password: $encrypted,
name: $name
})
RETURN u
""",
email=email, encrypted=encrypted, name=name # (2)
).single()
#end create_user function definition
try:
with self.driver.session() as session:
result = session.execute_write(create_user, email, encrypted, name)
user = result['u']
payload = {
"userId": user["userId"],
"email": user["email"],
"name": user["name"],
}
payload["token"] = self._generate_token(payload)
return payload
except ConstraintError as err:
# Pass error details through to a ValidationException
raise ValidationException(err.message, {
"email": err.message
})
# TODO: Handle unique constraint error
if email != "graphacademy@neo4j.com":
raise ValidationException(
f"An account already exists with the email address {email}",
{"email": "An account already exists with this email"}
)
# Build a set of claims
payload = {
"userId": "00000000-0000-0000-0000-000000000000",
"email": email,
"name": name,
}
# Generate Token
payload["token"] = self._generate_token(payload)
return payload
# end::register[]
Can you try creating a .env
file in the project root and adding JWT_SECRET=somerandomstring
to it?
Can you try creating a
.env
file in the project root and addingJWT_SECRET=somerandomstring
to it?
It solved the issue. First create the .env file using the command "touch .env" and write the content provided in the screenshot.
I followed the tutorial, but I'm experiencing an issue. Do you have any suggestions for how to resolve it?