Class: SGS::Authenticate
- Inherits:
-
Object
- Object
- SGS::Authenticate
- Defined in:
- lib/sgs/authenticate.rb
Instance Method Summary collapse
-
#cookies ⇒ Object
Hash Cookies used by SGS.
- #initialize(args) ⇒ Authenticate constructor
Constructor Details
#initialize(args) ⇒ Authenticate
7 8 9 |
# File 'lib/sgs/authenticate.rb', line 7 def initialize(args) @username, @password = args.fetch(:username), args.fetch(:password) end |
Instance Method Details
#cookies ⇒ Object
Returns Hash Cookies used by SGS.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sgs/authenticate.rb', line 14 def @_cookies ||= lambda { url = %W{ http://marknad.sgsstudentbostader.se/s3.aspx? page=pgRedirect& verifylogin=y& mg=1& id=/se/mina-sidor& client=#{@username}& pin=#{@password}& url=http://www.sgsstudentbostader.se/setlogin.aspx }.join("") RestClient.get(url) do |r1| if r1.headers[:location] =~ /blnInloggadFull=false/ raise NotAuthorisedError.new("Invalid username of password") end RestClient.get(r1.headers[:location]) do |r2| return r2. end end }.call end |