Sha256: dee06e050ffafe9e6b9e84e470de3f4a281bcb0d76d2a58e374ea75890e10ded

Contents?: true

Size: 895 Bytes

Versions: 1

Compression:

Stored size: 895 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)
        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

1 entries across 1 versions & 1 rubygems

Version Path
ucb_rails-0.0.14 app/controllers/ucb_rails/bootstrap_controller.rb