Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sign_in_token = true not persisting session #343

Open
mrpta opened this issue Jan 20, 2019 · 0 comments
Open

sign_in_token = true not persisting session #343

mrpta opened this issue Jan 20, 2019 · 0 comments

Comments

@mrpta
Copy link

mrpta commented Jan 20, 2019

Hi there,

I'm trying to use the gem to implement a 1-click login via email.

# config/initializers/simple_token_authentication.rb
SimpleTokenAuthentication.configure do |config|

    config.sign_in_token = true

end

# app/models/user.rb
class User < ActiveRecord::Base
    acts_as_token_authenticatable
end

# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
    acts_as_token_authentication_handler_for User

    # .....

    def after_successful_token_authentication
        # Make the authentication token to be disposable
        current_user.authentication_token = nil
        current_user.save!
    end

end

A visit to http://localhost:3000/?user_email=user@example.com&user_token=zeb_htxXLs4myJR591ac goes on to load the view. However fails to correctly load anything wrapped in a user_signed_in? called in a before_action. The after_successful_token_authentication hook correctly invalidates the token so on another refresh I get directed to the the Device sign in. At first I thought the initializer was ignored but I can successfully authenticate with another field by specifying the config.identifiers. Just lacking the session persistence.

Can you give me some advice? Probably not a bug - just me being dim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant