Module: MerbAuth::Controller::SessionsBase::InstanceMethods

Defined in:
lib/merb-auth/controller/sessions_base.rb

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/merb-auth/controller/sessions_base.rb', line 17

def create
  self.current_ma_user = MA[:user].authenticate(params[MA[:login_field]], params[:password])
  if logged_in?
    if params[:remember_me] == "1"
      self.current_ma_user.remember_me
      expires = Time.parse(self.current_ma_user.remember_token_expires_at.to_s)
      cookies[:auth_token] = { :value => self.current_ma_user.remember_token , :expires => expires }
    end
    #redirect_back_or_default('/')
    #redirect MA[:redirect_after_login] || '/'

    redirect_back_or_default(MA[:redirect_after_login] || '/')
  else
    render :new
  end
end

#destroyObject



34
35
36
37
38
39
# File 'lib/merb-auth/controller/sessions_base.rb', line 34

def destroy
  self.current_ma_user.forget_me if logged_in?
  cookies.delete :auth_token
  session.clear
  redirect_back_or_default('/')
end

#newObject



13
14
15
# File 'lib/merb-auth/controller/sessions_base.rb', line 13

def new
  render
end