18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/omniauth/strategies/owa.rb', line 18
def callback_phase
uid, password = request.params.values_at "uid", "password"
conn = Faraday.new url: options.base_url
conn.basic_auth uid, password
response = conn.get("/owa/?ae=Dialog&t=AddressBook&ctx=1&sch=#{uid}")
return fail!(:invalid_credentials) unless response.success?
search_results = response.body
id = search_results.match(/<h1><a href="#" id="([^"]+)"/)[1]
details = conn.get("/owa/?ae=Item&t=AD.RecipientType.User&id=#{CGI.escape id}").body
@info = {}
@info[:first_name] = details.match(/<td[^>]*>First name<\/td><td[^>]*>([^<]*)/)[1]
@info[:last_name] = details.match(/<td[^>]*>Last name<\/td><td[^>]*>([^<]*)/)[1]
@info[:email] = details.match(/<td[^>]*>E-mail<\/td><td[^>]*>([^<]*)/)[1]
@info[:name] = "#{@info[:first_name]} #{@info[:last_name]}"
super
rescue
fail! :internal_error
end
|