Sha256: f8d2bfd175258d2bff194292abfc4db4ce1930821d6579794b88e9a2e18ca29d

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'mountain-goat/helpers/mg/mg_helper'

class Mg < ActionController::Base
  
  layout 'mountain_goat'
  
  before_filter :verify_access
  
  self.prepend_view_path File.join([File.dirname(__FILE__), '../../views/mountain_goat/'])
  
  private
  
  def store_location(url = nil)
    if url.nil?
      if request.method == :post && request.params.count > 0
        session[:mg_return_to] = "#{request.request_uri}?" + encode_parameters(request.params)
      else
        session[:mg_return_to] = request.request_uri
      end
    else
      session[:mg_return_to] = url
    end
    
    logger.warn "Storing location: #{session[:mg_return_to]}"
  end
  
  def redirect_back_or_default(default)
    redirect_to(session[:mg_return_to] || default)
    session[:mg_return_to] = nil
  end
  
  def verify_access
    return if session[:mg_access] == true
    store_location
    redirect_to mg_login_url and return
  end
  
  def self.password_digest(password, salt)
    site_key = '1e9532ea39233e1e2786d80fde90d708c0918d2d'
    stretches = 10
    digest = site_key
    stretches.times do
      digest = secure_digest(digest, salt, password, site_key)
    end
    digest
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mountain-goat-1.0.6pre1 lib/mountain-goat/controllers/mg/mg.rb