Sha256: 076d19a2507c0e6f9453d426037c76493e08735b0e858e3377a42b2ac52deec2

Contents?: true

Size: 1.12 KB

Versions: 20

Compression:

Stored size: 1.12 KB

Contents

# Basic Marty single-page application with authentication.
#
# == Extending Marty::AuthApp
# DOCFIX
class Marty::AuthApp < Marty::SimpleApp
  js_configure do |c|
    c.mixin
  end

  # Set the Logout button if current_user is set
  def menu
    [].tap do |menu|
      user = Mcfly.whodunnit
      if !user.nil?
        menu << "->" << {
          text: user.name,
          menu: user_menu,
          name: "sign_out",
        }
      else
        menu << "->" << :sign_in
      end
    end
  end

  def user_menu
    [:sign_out]
  end

  action :sign_in do |c|
    c.icon = :door_in
  end

  action :sign_out do |c|
    c.icon = :door_out
    c.text = "Sign out #{Mcfly.whodunnit.name}" if Mcfly.whodunnit
  end

  endpoint :sign_in do |params,this|
    user = Marty::User.try_to_login(params[:login], params[:password])

    if user
      Netzke::Base.controller.set_user(user)
      this.netzke_set_result(true)
    else
      this.netzke_set_result(false)
      this.netzke_feedback("Wrong credentials")
    end
  end

  endpoint :sign_out do |params,this|
    Netzke::Base.controller.logout_user
    this.netzke_set_result(true)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
marty-0.5.32 app/components/marty/auth_app.rb
marty-0.5.31 app/components/marty/auth_app.rb
marty-0.5.30 app/components/marty/auth_app.rb
marty-0.5.29 app/components/marty/auth_app.rb
marty-0.5.28 app/components/marty/auth_app.rb
marty-0.5.27 app/components/marty/auth_app.rb
marty-0.5.26 app/components/marty/auth_app.rb
marty-0.5.25 app/components/marty/auth_app.rb
marty-0.5.24 app/components/marty/auth_app.rb
marty-0.5.23 app/components/marty/auth_app.rb
marty-0.5.21 app/components/marty/auth_app.rb
marty-0.5.20 app/components/marty/auth_app.rb
marty-0.5.19 app/components/marty/auth_app.rb
marty-0.5.18 app/components/marty/auth_app.rb
marty-0.5.17 app/components/marty/auth_app.rb
marty-0.5.16 app/components/marty/auth_app.rb
marty-0.5.15 app/components/marty/auth_app.rb
marty-0.5.14 app/components/marty/auth_app.rb
marty-0.5.13 app/components/marty/auth_app.rb
marty-0.5.12 app/components/marty/auth_app.rb