Sha256: 91a7e459f6c6266e7be449a8b841fb8d9537bf6ba7d64e82d0a1c43c0409d59e
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
module OmniAuth module Strategies class GitLab include OmniAuth::Strategy option :fields, [:email] option :site, nil option :v, 'v3' option :uid_field, :email option :on_login, nil option :on_registration, nil option :on_failed_registration, nil def request_phase if options[:on_login] options[:on_login].call(self.env) else form = OmniAuth::Form.new(:title => (options[:title] || "Gitlab Verification"), :url => callback_path) form.text_field 'Email', 'email' form.password_field 'Password', 'password' form.button "Sign In" form.to_response end end def callback_phase return fail!(:invalid_credentials) unless identity super end uid{ identity['id'].to_s } info do { :name => identity['name'], :email => identity['email'], :nickname => identity['username'] } end credentials do { :token => identity['private_token'] } end extra do { :raw_info => identity } end def identity @identity ||= begin conn = Faraday.new(:url => options[:site]) resp = conn.post do |req| req.url "/api/#{options[:v]}/session" req.headers['Content-Type'] = 'application/json' req.params = { :email => request['email'], :password => request['password'] } end resp.success? ? MultiJson.decode(resp.body) : nil end end end end end OmniAuth.config.add_camelization 'gitlab', 'GitLab'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omniauth-gitlab-0.0.4 | lib/omniauth/strategies/gitlab.rb |