Sha256: a6d1c9b153899c99802f2838d7054e7b0c09d644c85e6af3af60f1f4f8c66090

Contents?: true

Size: 873 Bytes

Versions: 3

Compression:

Stored size: 873 Bytes

Contents

# For demo purposes. Not used in testing.
class SimpleAuthenticationComponent < Netzke::Base
  action :sign_in

  action :sign_out

  def configure(c)
    super
    c.tbar = signed_in? ? [current_user_info, "->", :sign_out] : ["->", :sign_in]
  end

  js_configure do |c|
    c.on_sign_in = <<-JS
      function(){
        this.signIn();
      }
    JS

    c.on_sign_out = <<-JS
      function(){
        this.signOut();
      }
    JS

    c.reload_page = <<-JS
      function(){window.location = window.location;}
    JS
  end

  endpoint :sign_in do |params,this|
    session[:user_id] = 1
    this.reload_page
  end

  endpoint :sign_out do |params,this|
    session.delete(:user_id)
    this.reload_page
  end

  def current_user_info
    session[:user_id] && "Signed in as user#: #{session[:user_id]}" || ""
  end

  def signed_in?
    !!session[:user_id]
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
netzke-core-0.8.4 test/core_test_app/app/components/simple_authentication_component.rb
netzke-core-0.8.3 test/core_test_app/app/components/simple_authentication_component.rb
netzke-core-0.8.2 test/core_test_app/app/components/simple_authentication_component.rb