deactivate a user (e.g., User.where("active = true and admin != true").update_all(active: false))
have the user try to log in or otherwise get a validation token created
activate the user with things like User.all.update_all(active: true).
Even though the user record shows “true” in the active field, they couldn’t log in. I tried a whole bunch of ways to activate a user (e.g., i called user.activate and user.save) and nothing kept the user from getting the “We sent an activation email, you need to follow those instructions” link when trying to log in until I finally found the email token and did
token.confirmed=true
token.save
and then the user could log in.
The lesson is probably don’t deactivate a user unless you really mean it.
Well, not really. SSO can skirt the requirement. And rake admin:create will activate a user. I just deactivated the all as part of the import and the admin didn’t want them deactivated, and the test site has outgoing mail disabled.
I thought that the ACTIVATE button on the admin screen would activate a user too, without sending the email.
Sorry for the delay @pfaffman, travelling this week.
Looks like we’ve got a real bug here. The activate button works if the user has never been activated before (sign up, don’t click on the link in email), however it fails if the user was deactivated.
Repro steps:
User signs up on site and activates their account as normal.
Admin goes to user admin page and click Deactivate
User is logged out.
Admin clicks “Activate Account” - the page refreshes but the user is still deactivated.
Admin gets annoyed and keeps clicking Activate Account, to no avail .
In that case, the problem appears to have to do with there being an email token has been created. I looked at the code and couldn’t quite see where the problem is.