Oliver D
Oliver D

Reputation: 2889

Should Token created when the user registers or login?

I have an API created by one of my team :),

And he made an endpoints "Register/Login"

his thought

When user create a user we save his data and the endpoint response it " without generating a Token"

so i can't navigate him to other screens cuz I make a request based on his Token,

So he wants me to navigate user after register to the login screen then Login endpoint will response the Token

But I think it's not a nice way and not improve UX.

So what you think we do?

generate Token in the register or log in?

Upvotes: 2

Views: 4393

Answers (1)

Arber Sylejmani
Arber Sylejmani

Reputation: 2108

The way I see this:

Solution 1:

You have him change the register API so that returns a token for you and you keep doing whatever you do with it.

Solution 2:

By registering, I'm assuming they type in a username/email, some personal details and a password!? So you have all the data to log the user in after registration. Upon successful registration, use the same username/email and password from memory (do not store them in browser storage) and call the login api to get the token (you only redirect after you've gotten the token) - so UX doesn't suffer here.


P.S. Instead of "fighting" one another over who's solution is better, try to work together in a solution. This is clearly an "I told you so" attempt - hence why I gave you two solution where both sides can do the work. Both of you can implement a solution without affecting UX, it's a matter of who's more stubborn :P

Upvotes: 2

Related Questions