Sha256: 64119ea49c75dc4c74741521fa0573b9501047d3fed7e35a70047dd770770aa6

Contents?: true

Size: 731 Bytes

Versions: 9

Compression:

Stored size: 731 Bytes

Contents

class SessionsController < ApplicationController

  def new
  end

  def create
    user = User.find_by_email(params[:email])
    if user && user.authenticate(params[:password])
      if params[:remember_me]
        cookies.permanent[:auth_token] = user.auth_token
      else
        cookies[:auth_token] = user.auth_token
      end
      redirect_to (session[:target_page] || safe_root_url), notice: t('authentication.login_confirmation')
      session[:target_page] = nil
    else
      flash.now.alert = t('authentication.warning.email_or_password_invalid')
      render "new"
    end
  end

  def destroy
    cookies.delete(:auth_token)
    redirect_to safe_root_url, notice: t('authentication.logout_confirmation')
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tkh_authentication-0.1.2 app/controllers/sessions_controller.rb
tkh_authentication-0.1.1 app/controllers/sessions_controller.rb
tkh_authentication-0.1 app/controllers/sessions_controller.rb
tkh_authentication-0.0.12 app/controllers/sessions_controller.rb
tkh_authentication-0.0.11 app/controllers/sessions_controller.rb
tkh_authentication-0.0.10 app/controllers/sessions_controller.rb
tkh_authentication-0.0.9 app/controllers/sessions_controller.rb
tkh_authentication-0.0.8 app/controllers/sessions_controller.rb
tkh_authentication-0.0.7 app/controllers/sessions_controller.rb