Sha256: 7e0a4125109f17321c27a2832868d4dbd6ac84c46e0c32783258dacf21a2dfe4

Contents?: true

Size: 871 Bytes

Versions: 2

Compression:

Stored size: 871 Bytes

Contents

Janus::Manager.after_login do |user, manager, options|
  if user.respond_to?(:generate_session_token!)
    user.generate_session_token! if user.session_token.nil?
    
    session = manager.session(options[:scope])
    session[:session_token] = user.session_token
  end
end

Janus::Manager.after_authenticate do |user, manager, options|
  if user.respond_to?(:session_token)
    session = manager.session(options[:scope])
    session[:session_token] = user.session_token
  end
end

Janus::Manager.after_logout do |user, manager, options|
  user.destroy_session_token! if user.respond_to?(:destroy_session_token!)
end

Janus::Manager.after_fetch do |user, manager, options|
  if user.respond_to?(:session_token)
    scope   = options[:scope]
    session = manager.session(scope)
    manager.unset_user(scope) unless session[:session_token] == user.session_token
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
janus-0.6.0 lib/janus/hooks/remote_authenticatable.rb
janus-0.5.0 lib/janus/hooks/remote_authenticatable.rb