This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

if the user from uaa is not in cc db, add a proxyone

  • Loading branch information...
tiewei committed Jun 4, 2013
1 parent 6a75345 commit 49fc960330dc881adc199021b33c9c83d25fd85e
Showing with 12 additions and 0 deletions.
  1. +12 −0 cloud_controller/app/controllers/application_controller.rb
@@ -82,6 +82,18 @@ def fetch_user_from_token
if (!user_email.nil?)
CloudController.logger.debug("user_email decoded from token is #{user_email.inspect}")
@current_user = ::User.find_by_email(user_email)
+ if @current_user.nil? && uaa_enabled?
+ CloudController.logger.debug("#{user_email.inspect} from uaa is not in CloudController DB, Try to Create a proxy one")
+ user = ::User.new :email => user_email
+ user.set_and_encrypt_password(user_email)
+ if user.save
+ @current_user = ::User.find_by_email(user_email)
+ CloudController.logger.info("proxy user #{user_email.inspect} from uaa is added into CloudController DB")
+ else
+ @current_user = nil
+ CloudController.logger.warn("proxy user #{user_email.inspect} from uaa is not added into CloudController DB")
+ end
+ end
end
unless @current_user.nil?

0 comments on commit 49fc960

Please sign in to comment.