Вопрос

Is it safe to login user automatically after registration?

User fills registration form, some info message is sent to his mailbox, and what then:

  • User redirected to login page asking him for credentials;

OR

  • User auto-logins as his newly created user?

I feel something not safe enough in auto-login, but can't figure it out!

Это было полезно?

Решение

If they just filled out the login information and you're not concerned about confirming that the email address is legit, then there shouldn't be a problem just logging them in directly.

However, you open yourself up to people/bots creating bogus accounts (at least ones without legitimate email addresses). If you're concerned about that (not sure it this is a public facing app or intranet, etc) then you should at least verify the email address by sending a link with a guid or some identifier that you can track back. Then you can let them log-in once they are confirmed.

You could also just tie it to their StackExchange/Facebook/OpenID/etc account and not make users fill out yet another form and worry about maintaining all that information.

Другие советы

They should need to login. Also the confirmation email should not contain their password. If they managed to give you the wrong email address and you automatically log them in then someone else has access to their account now. This holds even if you have them type their email address twice. Sometimes people make the same mistake twice in a row.

It can be safe to auto login if the user already has an active session as the correct user during the confirmation step. If you think about it, it's not actually "automatically logging them in" but simply keeping them logged in as they was before.

  1. User registers
  2. Keep a session identifying the user
  3. User navigates to the confirmation page (linked in email)
  4. You activate the account

During all that time, there was no reason to end the session. The only reason you would want to end the session (or not create one in the first place) is if your permissions are not properly set to allow someone to login / create a session without giving them higher privileges than an unregistered user.

Now, be sure not to automatically identify the user as X simply because this person navigated to the confirmation page of user X. If a user navigates to this page but does not already have a session open, do not assume he knows the password.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top