Class: Login

Inherits:
Dynasnip show all
Includes:
Helper
Defined in:
lib/vanilla/dynasnips/login.rb

Defined Under Namespace

Modules: Helper

Instance Attribute Summary

Attributes inherited from Vanilla::Renderers::Base

#app

Instance Method Summary collapse

Methods included from Helper

#current_user, #logged_in?, #login_required

Methods inherited from Dynasnip

all, attribute, build_snip, #method_missing, persist!, persist_all!, snip_attributes, snip_name, usage

Methods inherited from Vanilla::Renderers::Base

escape_curly_braces, #include_snips, #initialize, #prepare, #process_text, #raw_content, render, #render, #render_without_including_snips, snip_regexp

Constructor Details

This class inherits a constructor from Vanilla::Renderers::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Dynasnip

Instance Method Details

#delete(*args) ⇒ Object



38
39
40
41
# File 'lib/vanilla/dynasnips/login.rb', line 38

def delete(*args)
  app.request.session['logged_in_as'] = nil
  "Logged out"
end

#get(*args) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/vanilla/dynasnips/login.rb', line 21

def get(*args)
  if logged_in?
    
  else
    render(self, 'template')
  end
end

#post(*args) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/vanilla/dynasnips/login.rb', line 29

def post(*args)
  if app.config[:credentials][cleaned_params[:name]] == MD5.md5(cleaned_params[:password]).to_s
    app.request.session['logged_in_as'] = cleaned_params[:name]
    
  else
    "login fail!"
  end
end