Created
October 15, 2010 17:32
-
-
Save Whoops/628594 to your computer and use it in GitHub Desktop.
This file contains 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
require 'rubygems' | |
require 'sinatra/base' | |
require 'omniauth' | |
require 'openid/store/filesystem' | |
require 'sinatra/mongomatic' | |
require 'models.rb' | |
class Teste < Sinatra::Base | |
register Sinatra::Mongomatic | |
conn = Mongo::Connection.new('flame.mongohq.com', 27064) | |
conn.add_auth('RMU','rmu','unicorn') | |
Mongomatic.db = conn.db('RMU') | |
puts User.empty? | |
u = User.new(:name => "", :age => 12) | |
puts u["age"], u.insert | |
use OmniAuth::Builder do | |
provider :open_id, OpenID::Store::Filesystem.new('/tmp') | |
provider :twitter, 'ZrxnngDLk0AXdOy17ZVqxg', 'LB3ackpiT0fZo0wiVvT4kmVZk8LuyPKOoCx3aYxew' | |
end | |
enable :sessions | |
enable :run | |
get '/' do | |
<<-HTML | |
<a href='/auth/twitter'>Sign in with Twitter</a> | |
<form action='/auth/open_id' method='post'> | |
<input type='text' name='identifier'/> | |
<input type='submit' value='Sign in with OpenID'/> | |
</form> | |
HTML | |
end | |
get '/auth/:name/callback' do | |
auth = request.env['rack.auth'] | |
# do whatever you want with the information! | |
"#{auth.inspect}" + "<p></p><p></p> | |
#{auth['credentials']['token']}<br> | |
#{auth['credentials']['secret']}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment