Hi, I'm a new user, testing out devise, and I'm having some troubles getting things to work. So far, I've been able to create a user in a user table in a couple of different ways (twitter and email), and I've been able to see that Devise thinks I'm logged in. But I have no access to a current_user, and my user_signed_in? returns false.
When I try to sign in, I see something like this appear in the logs (the user from my users table that I log in with is found by matching a twitter uid in the UserType1 table, then finding the associated user in the User table):
UserType1 Load (0.1ms) SELECT "user_type1s".* FROM "user_type1s" WHERE "user_type1s"."twitter_uid" = ########## LIMIT 1
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."type_id" = ? AND "users"."type_type" = ? LIMIT 1 [["type_id", 2], ["type_type", "UserType1"]]
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2 ORDER BY "users"."id" ASC LIMIT 1
Redirected to
http://localhost:3000/Completed 302 Found in 8ms (ActiveRecord: 0.8ms)
And before the root page loads, I get something like this:
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2 ORDER BY "users"."id" ASC LIMIT 1
If I sign up more users, I get the user id number incrementing correctly, and when I look at the table, I'm correctly seeing the "sign in count" correctly incrementing both between when I first sign up and log in (going from 0 to 1) and when my twitter user logs in again after (going from 1 to 2, or however high I want it to go). If I try to use the /users/sign_in path, I get a flash saying that I'm already logged in. If I run that select query in a rails console, I get the correct user back.
I've been looking around, and I've seen some answers that don't appear to work for me: I've completely turned off CSRF protection for now (removed the line from my application controller) and my devise_parameter_sanitizer for sign_in is set to permit everything in my user controller.
I also see this at the bottom of my session after I've signed in:
{"session_id"=>"753cb906d43b2636ae990840687bca44", "_csrf_token"=>"Z9+N8qeTvQRFMdKrn78sR+ZLDQXpnyg2yJV86j1bqTM=",
"oauth"=>{"twitter"=>{"callback_confirmed"=>true}}, "warden.u...@fake.com.key"=>"te...@fake.com", "warden.user.user.key"=>[[2],
"$2a$10$.TZPi/kmREve96ymRc2mOe"], "flash"=>{"discard"=>["alert"], "flashes"=>{"alert"=>"You are already signed in."}}}},
@delegate={"session_id"=>"753cb906d43b2636ae990840687bca44", "_csrf_token"=>"Z9+N8qeTvQRFMdKrn78sR+ZLDQXpnyg2yJV86j1bqTM=",
"oauth"=>{"twitter"=>{"callback_confirmed"=>true}}, "warden.u...@fake.com.key"=>"te...@fake.com",
"warden.user.user.key"=>[[2], "$2a$10$.TZPi/kmREve96ymRc2mOe"], "flash"=>{"discard"=>["alert"],
"flashes"=>{"alert"=>"You are already signed in."}}}, @loaded=true, @exists=true>
I'm not exactly sure how to read that, but it seems like Warden knows the user's id, what the user's email is and how the authentication was done.
What could be causing my setup to not actually set anything when I do an "authenticate_user!", when it knows who the user is supposed to be and can find it? Is there any additional logging I can do to see where things are going wrong?