Skip to content

BACKEND - Implement email and username validation in register/login endpoints #50

@Vegard-S

Description

@Vegard-S

##What
Implement email and username validation in register and login endpoints.

Check if tests validate the added functionality.

##Why
When a user creates a new profile the email needs to be validated so that it complies with the rules and that the email does not exist in database. the username needs to be syntax validated.
When a user logs in, the email needs to be validated as an existing email in the database. Validating syntax is not necessary on login.

Making sure tests are updated.

##How
Create:
Add a call to the validate email helper function. "Helpers.Validator.Email(email);"
Check if the email exists in the database:
"
var emailExists = repository.GetAllFiltered(q => q.Email == email);
if (emailExists.Count() != 0) return TypedResults.BadRequest("Email already exists");
"
"
string result = Helpers.Validator.Username(username);
if (result != "Accepted") return TypedResults.BadRequest(result);
"

Login:
Check if the email exists in the database:
"
var emailExists = repository.GetAllFiltered(q => q.Email == email);
if (emailExists.Count() != 0) return TypedResults.BadRequest("Email already exists");
"

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions