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

undefined method `after_session_save=' for Passwordless:Module #48

Closed
aurels opened this issue Mar 6, 2019 · 12 comments
Closed

undefined method `after_session_save=' for Passwordless:Module #48

aurels opened this issue Mar 6, 2019 · 12 comments

Comments

@aurels
Copy link

aurels commented Mar 6, 2019

Hello,

I'm trying to use this :
https://github.com/mikker/passwordless#customize-the-way-to-send-magic-link

So I add a Passwordless.after_session_save = to my initializer. Ruby tells me it's not defined.
I can see in the source code of passwordless (0.6.0) that it's well defined in lib/passwordless.rb.

Am I missing something ? Thanks.

@mikker
Copy link
Owner

mikker commented Mar 6, 2019

Hi @aurels! That sounds weird. Where are you trying to set this? In an initializer?

@aurels
Copy link
Author

aurels commented Mar 6, 2019

Yep @mikker, here is my initializer file :

# Token timeout
Passwordless.timeout_at = lambda { 2.hours.from_now }

# Session Expiry
Passwordless.expires_at = lambda { 72.hours.from_now }

Passwordless.after_session_save = lambda do |session|
  email = @session.authenticatable.email
  link  = users.token_sign_in_url(session.token)

  puts "New connection link generated for #{email}"
  puts "#{link}"

  user    = User.find_by!(email: email)
  account = user.accounts.first

  Mailer.passwordless_link(account, email, link)
end

@mikker
Copy link
Owner

mikker commented Mar 6, 2019

And you are sure you're using the latest version of the gem (bundle show passwordless) and restarted the server? Just making sure.

@aurels
Copy link
Author

aurels commented Mar 6, 2019

Yes :

git:(passwordless) ✗ docker-compose -f docker/development/docker-compose.yml run web bundle show passwordless
/usr/local/bundle/gems/passwordless-0.6.0

@aurels
Copy link
Author

aurels commented Mar 6, 2019

I'm glad to read I'm not crazy :p

@aurels
Copy link
Author

aurels commented Mar 6, 2019

Here is the full stacktrace in case it may help :
https://gist.github.com/aurels/9b13240e8f6945ccc84f3dba1e76d062

Methods :

irb(main):004:0> Passwordless.methods.sort
=> [:!, :!=, :!~, :<, :<=, :<=>, :==, :===, :=~, :>, :>=, :__id__, :__send__, :`, :acts_like?, :alias_attribute, 
:ancestors, :anonymous?, :as_json, :attr_internal, :attr_internal_accessor, :attr_internal_reader, 
:attr_internal_writer, :autoload, :autoload?, :blank?, :cattr_accessor, :cattr_reader, :cattr_writer, :class, 
:class_eval, :class_exec, :class_variable_defined?, :class_variable_get, :class_variable_set, 
:class_variables, :clone, :concern, :concerning, :const_defined?, :const_get, :const_missing, :const_set, :constants, :deep_dup, :default_from_address, :default_from_address=, :define_singleton_method, :delegate, :delegate_missing_to, :deprecate, :deprecate_constant, :display, :dup, :duplicable?, :enum_for, :eql?, :equal?, :expires_at, :expires_at=, :extend, :freeze, :frozen?, :gem, :guess_for_anonymous, :hash, :html_safe?, :in?, :include, :include?, :included_modules, :inspect, :instance_eval, :instance_exec, :instance_method, :instance_methods, :instance_of?, :instance_values, :instance_variable_defined?, :instance_variable_get, :instance_variable_names, :instance_variable_set, :instance_variables, :is_a?, :itself, :kind_of?, :load_dependency, :mattr_accessor, :mattr_reader, :mattr_writer, :method, :method_defined?, :method_visibility, :methods, :module_eval, :module_exec, :mounted_as, :mounted_as=, :name, :nil?, :object_id, :parent, :parent_name, :parents, :prepend, :presence, :presence_in, :present?, :pretty_inspect, :pretty_print, :pretty_print_cycle, :pretty_print_inspect, :pretty_print_instance_variables, :private_class_method, :private_constant, :private_instance_methods, :private_method_defined?, :private_methods, :protected_instance_methods, :protected_method_defined?, :protected_methods, :psych_to_yaml, :psych_yaml_as, :public_class_method, :public_constant, :public_instance_method, :public_instance_methods, :public_method, :public_method_defined?, :public_methods, :public_send, :railtie_helpers_paths, :railtie_namespace, :railtie_routes_url_helpers, :rake_extension, :reachable?, :redefine_method, :redefine_singleton_method, :redirect_back_after_sign_in, :redirect_back_after_sign_in=, :remove_class_variable, :remove_instance_variable, :remove_possible_method, :remove_possible_singleton_method, :require_dependency, :require_or_load, :respond_to?, :send, :silence_redefinition_of_method, :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :suppress_warnings, :table_name_prefix, :taint, :tainted?, :tap, :thread_cattr_accessor, :thread_cattr_reader, :thread_cattr_writer, :thread_mattr_accessor, :thread_mattr_reader, :thread_mattr_writer, :timeout_at, :timeout_at=, :to_enum, :to_json, :to_param, :to_query, :to_s, :to_yaml, :to_yaml_properties, :token_generator, :token_generator=, :trust, :try, :try!, :unloadable, :untaint, :untrust, :untrusted?, :use_relative_model_naming?, :with_options, :yaml_as]

Something strange to me too :

Passwordless::VERSION
NameError: uninitialized constant Passwordless::VERSION

@mikker
Copy link
Owner

mikker commented Mar 6, 2019

Maybe try gem open passwordless to browse around and look if the code matches?

@aurels
Copy link
Author

aurels commented Mar 6, 2019

OK, it does not :

image

Maybe the 0.6.0 version on RubyGems.org is not the same as on Github ?

@mikker
Copy link
Owner

mikker commented Mar 6, 2019

We should've checked the CHANGELOG – turns out the feature isn't released yet 😆

Here's 0.6.0: https://github.com/mikker/passwordless/blob/v0.6.0/lib/passwordless.rb

I'll do a release right away.

@mikker
Copy link
Owner

mikker commented Mar 6, 2019

0.7.0 is released to Rubygems 👍

@mikker mikker closed this as completed Mar 6, 2019
@aurels
Copy link
Author

aurels commented Mar 6, 2019

Rha! Thanks.

Really useful and well implemented project BTW. Do you have a list of future enhancements somewhere ? I'd be happy to contribute.

@mikker
Copy link
Owner

mikker commented Mar 6, 2019

I only have the Issues on here but as far as I remember there’s a few features in there.

PRs are very welcome! And thanks 😊 do my best.

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

2 participants