4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'app/controllers/ucb_rails/bootstrap_controller.rb', line 4
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
|