Sha256: 0a5962c9b5f45ec674dd57b76410ccc23e0dd80c3313bcf36b2276a00dda190f

Contents?: true

Size: 998 Bytes

Versions: 1

Compression:

Stored size: 998 Bytes

Contents

class SessionsController < ApplicationController
  layout 'sessions'
  before_filter :login_required, :only => [:destroy, :show]

  def new
  end

  def create
    if user_dn = User.authenticate( params[:user][:uid], params[:user][:password] ) # REST/OAuth?
      flash[:notice] = t('flash.session.login_successful')
      session[:dn] = user_dn
      session[:password_plaintext] = params[:user][:password]

      #redirect_back_or_default schools_url
      redirect_back_or_default root_path
    else
      flash[:notice] = t('flash.session.failed')
      render :action => :new
    end
  end

  def show
    @user = User.find(session[:dn])
    respond_to do |format|
      format.json  { render :json => @user.to_json(:methods => :managed_schools) }
    end
  end

  def destroy
    # Remove dn and plaintext password values from session
    session.delete :password_plaintext
    session.delete :dn
    flash[:notice] = t('flash.session.logout_successful')
    redirect_to login_path
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puavo_authentication-0.2.0 app/controllers/sessions_controller.rb