Skip to content

Instantly share code, notes, and snippets.

@dux
Created April 9, 2012 21:06
Show Gist options
  • Save dux/2346537 to your computer and use it in GitHub Desktop.
Save dux/2346537 to your computer and use it in GitHub Desktop.
cloudero connect
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