Sha256: 86c04725fc38f217d4aa4b8e43ed42e6f56d47f78cd0dcdf2b3d5cf8f4d1226c

Contents?: true

Size: 1.09 KB

Versions: 27

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

27 entries across 27 versions & 1 rubygems

Version Path
marty-2.5.2 app/components/marty/auth_app.rb
marty-2.5.1 app/components/marty/auth_app.rb
marty-2.5.0 app/components/marty/auth_app.rb
marty-2.4.9 app/components/marty/auth_app.rb
marty-2.4.8 app/components/marty/auth_app.rb
marty-2.4.7 app/components/marty/auth_app.rb
marty-2.4.6 app/components/marty/auth_app.rb
marty-2.4.5 app/components/marty/auth_app.rb
marty-2.4.4 app/components/marty/auth_app.rb
marty-2.4.3 app/components/marty/auth_app.rb
marty-2.4.2 app/components/marty/auth_app.rb
marty-2.4.1 app/components/marty/auth_app.rb
marty-2.4.0 app/components/marty/auth_app.rb
marty-2.3.15 app/components/marty/auth_app.rb
marty-2.3.14 app/components/marty/auth_app.rb
marty-2.3.13 app/components/marty/auth_app.rb
marty-2.3.12 app/components/marty/auth_app.rb
marty-2.3.11 app/components/marty/auth_app.rb
marty-2.3.10 app/components/marty/auth_app.rb
marty-2.3.9 app/components/marty/auth_app.rb