Valamburi M
Valamburi M

Reputation: 702

REST API Http Status code for Unconfirmed email but successful login

I have a use case here, a user registers in a website and has got an account activation link through email. User tries to login without activating his account.

What would be the Http status code for the login request, both username and password is correct but he has not yet activated his account from the activation link through email.

Http Status Code: XXX

Http Response

{ message: "your email address has not been confirmed yet", description: "Please confirm your account from the activation link sent through email" }

Upvotes: 4

Views: 2484

Answers (1)

Pratham
Pratham

Reputation: 547

I believe, 401 Unauthorized is the better choice here over 403 Forbidden because 403 is used to depict that client is authenticated but trying to access the resource which is not permitted to them.

It could be any endpoint.

Howerver, in this case, the confirmation of email is still pending which is related to authentication. Hence, sending 401 Unauthorized would make more sense to me here.

Although, it's debatable. We can consider this situation middleware in both things. I guess, 401 and 403 both are fine.

Upvotes: 1

Related Questions