Sha256: a2bd8caba69b2a22675230eaf48c1eb765038dfb539c052de10a42ab6efe21ce

Contents?: true

Size: 1.09 KB

Versions: 34

Compression:

Stored size: 1.09 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_cls = 'fa fa-sign-in-alt gylph'
  end

  action :sign_out do |c|
    c.icon_cls = 'fa fa-sign-out-alt gylph'
    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

34 entries across 34 versions & 1 rubygems

Version Path
marty-6.1.0 app/components/marty/auth_app.rb
marty-5.2.0 app/components/marty/auth_app.rb
marty-5.1.4 app/components/marty/auth_app.rb
marty-5.1.3 app/components/marty/auth_app.rb
marty-5.1.2 app/components/marty/auth_app.rb
marty-5.1.1 app/components/marty/auth_app.rb
marty-5.1.0 app/components/marty/auth_app.rb
marty-3.1.0 app/components/marty/auth_app.rb
marty-3.0.1 app/components/marty/auth_app.rb
marty-4.0.0.rc2 app/components/marty/auth_app.rb
marty-3.0.0 app/components/marty/auth_app.rb
marty-2.9.3 app/components/marty/auth_app.rb
marty-2.9.2 app/components/marty/auth_app.rb
marty-2.9.1 app/components/marty/auth_app.rb
marty-2.8.0 app/components/marty/auth_app.rb
marty-2.7.3 app/components/marty/auth_app.rb
marty-2.7.2 app/components/marty/auth_app.rb
marty-2.7.1 app/components/marty/auth_app.rb
marty-2.7.0 app/components/marty/auth_app.rb
marty-2.6.8 app/components/marty/auth_app.rb