Sha256: 0822981bcf24bff0fb0d6a95cb6ebe7cffd319a26565462a6469122ef06d71b7

Contents?: true

Size: 923 Bytes

Versions: 12

Compression:

Stored size: 923 Bytes

Contents

class UcbRails::BootstrapController < ApplicationController
  skip_before_filter :ensure_authenticated_user
  
  def index
    if RailsEnvironment.not_development?
      raise ActionController::RoutingError, "No route matches [#{env['REQUEST_METHOD']}] #{env['PATH_INFO'].inspect}"
    end

    if UcbRails::User.count > 0
      return render_text("Can't bootstrap.  Already have users.")
    end
    
    if uid.present?
      UCB::LDAP::Person.find_by_uid(uid).tap do |e|
        return render_text("Bad uid: #{uid.inspect}") if e.blank?
        user = UcbRails::UserLdapService.create_user_from_uid(uid)
        user.update_attributes({admin: true}, without_protection: true)
        redirect_to login_path
      end
    else
      return render_text "Must provide a uid: /ucb_rails/bootstrap/:uid"
    end
  end
  
  private
  
  def uid
    params[:uid]
  end
  
  def render_text(text)
    render text: text
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ucb_rails-0.0.13 app/controllers/ucb_rails/bootstrap_controller.rb
ucb_rails-0.0.12 app/controllers/ucb_rails/bootstrap_controller.rb
ucb_rails-0.0.11 app/controllers/ucb_rails/bootstrap_controller.rb
ucb_rails-0.0.10 app/controllers/ucb_rails/bootstrap_controller.rb
ucb_rails-0.0.9 app/controllers/ucb_rails/bootstrap_controller.rb
ucb_rails-0.0.8 app/controllers/ucb_rails/bootstrap_controller.rb
ucb_rails-0.0.7 app/controllers/ucb_rails/bootstrap_controller.rb
ucb_rails-0.0.6 app/controllers/ucb_rails/bootstrap_controller.rb
ucb_rails-0.0.5 app/controllers/ucb_rails/bootstrap_controller.rb
ucb_rails-0.0.4 app/controllers/ucb_rails/bootstrap_controller.rb
ucb_rails-0.0.3 app/controllers/ucb_rails/bootstrap_controller.rb
ucb_rails-0.0.2 app/controllers/ucb_rails/bootstrap_controller.rb