Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 9d1fe6358e
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (31 sloc) 0.807 kB
require "rubygems"
require "haml"
require "sinatra"
require 'nestful'
require 'digest/md5'
enable :sessions
helpers do
def login?
return !session[:email].nil?
end
def getGravatarURL
return "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(session[:email].strip.downcase)}"
end
end
get "/" do
haml :index
end
post "/auth/login" do
if params[:assertion]
data = Nestful.post "https://verifier.login.persona.org/verify", :format => :json, :params => { :assertion => "#{params[:assertion]}", :audience => "http://#{request.host}:#{request.port}" }
if data["status"] == "okay"
session[:email] = data["email"]
return data.to_json
end
end
return {:status => "error"}.to_json
end
get "/auth/logout" do
session[:email] = nil
redirect "/"
end
Jump to Line
Something went wrong with that request. Please try again.