Class: OmniAuth::Strategies::GitLab

Inherits:
Object
  • Object
show all
Includes:
OmniAuth::Strategy
Defined in:
lib/omniauth/strategies/gitlab.rb

Instance Method Summary collapse

Instance Method Details

#callback_phaseObject



26
27
28
29
# File 'lib/omniauth/strategies/gitlab.rb', line 26

def callback_phase
  return fail!(:invalid_credentials) unless identity
  super
end

#identityObject



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/omniauth/strategies/gitlab.rb', line 48

def identity
  @identity ||= begin
    conn = Faraday.new(:url => options[:site])
    resp = conn.post do |req|
      req.url '/api/v3/session'
      req.headers['Content-Type'] = 'application/json'
      req.params = { :email => request['email'], :password => request['password'] }
    end
    resp.success? ? MultiJson.load(resp.body) : nil
  end 
end

#request_phaseObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/omniauth/strategies/gitlab.rb', line 13

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