Sha256: a510810b7ce3087277d5134cac7c423569aa6bc4f7bb3948660c4281f30eaa95
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
require "omniauth" require "omniauth-webmaker" require "faraday" require "multi_json" module OmniAuth module Strategies class Webmaker include OmniAuth::Strategy class WebmakerError < StandardError attr_accessor :error def initialize(error) self.error = error end def message error end end option :login_server_url, "http://localhost:3000/api/user/authenticate" option :name, "webmaker" option :client_options, {} info do { :email => verify_webmaker } end def callback_phase super rescue WebmakerError => e fail! e.message, e end def verify_webmaker req_body = MultiJson.decode request.body conn = Faraday.new( options[:client_options].update(:url => options["login_server_url"]) ) response = conn.post( '', :assertion => req_body["assertion"], :audience => req_body["audience"] ) resp_body = MultiJson.decode(response.body) if resp_body.has_key? "user" resp_body["user"]["email"] elsif resp_body.has_key? "error" raise WebmakerError, "Error Logging In" elsif resp_body.has_key? "email" raise WebmakerError, "You Must <a href=\\\"https://webmaker.org\\\"> create a Webmaker account</a> to log in" else raise WebmakerError, "Unknown Error" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omniauth-webmaker-0.0.7 | lib/omniauth/strategies/webmaker.rb |