Sha256: e1bad1501d50a5c7501ee6cac0e7ab5edaaf082b3541891965315618bdef4146

Contents?: true

Size: 1.04 KB

Versions: 79

Compression:

Stored size: 1.04 KB

Contents

# Basic Marty single-page application with authentication.
#
# == Extending Marty::AuthApp
# DOCFIX
class Marty::AuthApp < Marty::SimpleApp
  client_class do |c|
    c.include :auth_app
  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,
          tooltip: 'Current user',
          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|
    user = Marty::User.try_to_login(params[:login], params[:password])
    user ? Netzke::Base.controller.set_user(user) :
      client.netzke_notify("Wrong credentials")

    !!user
  end

  endpoint :sign_out do
    Netzke::Base.controller.logout_user
    true
  end
end

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
marty-2.1.5 app/components/marty/auth_app.rb
marty-2.1.4 app/components/marty/auth_app.rb
marty-2.1.3 app/components/marty/auth_app.rb
marty-2.1.2 app/components/marty/auth_app.rb
marty-2.1.1 app/components/marty/auth_app.rb
marty-2.1.0 app/components/marty/auth_app.rb
marty-2.0.9 app/components/marty/auth_app.rb
marty-2.0.8 app/components/marty/auth_app.rb
marty-2.0.7 app/components/marty/auth_app.rb
marty-2.0.6 app/components/marty/auth_app.rb
marty-2.0.5 app/components/marty/auth_app.rb
marty-2.0.4 app/components/marty/auth_app.rb
marty-2.0.3 app/components/marty/auth_app.rb
marty-2.0.2 app/components/marty/auth_app.rb
marty-2.0.1 app/components/marty/auth_app.rb
marty-2.0.0 app/components/marty/auth_app.rb
marty-1.2.9 app/components/marty/auth_app.rb
marty-1.2.8 app/components/marty/auth_app.rb
marty-1.2.7 app/components/marty/auth_app.rb
marty-1.2.6 app/components/marty/auth_app.rb