Created
April 9, 2012 21:06
-
-
Save dux/2346537 to your computer and use it in GitHub Desktop.
cloudero connect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
before_filter :cloud_token | |
protected | |
def cloud_token | |
ct = params[:cloud_token] || return | |
url = "http://cloud.trifoliumdoo.com/token/#{ct}" | |
begin | |
data = HashWithIndifferentAccess.new JSON Http.get(url) | |
rescue | |
return render :text=>'BAD TOKEN' | |
end | |
user = data[:user] | |
org = data[:org] | |
u = User.where(:email=>user[:email]).first | |
unless u | |
u = User.create :name=>user[:email].first, :pass=>1 | |
u.set_pass rand(10000000000).to_s | |
u.save | |
end | |
session[:id] = u.id | |
return redirect_to '/' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment