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