Permalink
Browse files

Fixed bugs, added login return

  • Loading branch information...
1 parent c0054ed commit 0c82a6b22d84b426afe2182445805da2c6353848 @paradox460 committed Jun 20, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/snoo/account.rb
View
@@ -6,14 +6,16 @@ class Snoo
#
# @param username [String] The reddit account's username you wish to log in as
# @param password [String] The password of the reddit account
+ # @return [HTTParty::Response] The httparty request object.
def log_in username, password
login = self.class.post("/api/login", :body => {user: username, passwd: password, api_type: 'json'})
errors = login['json']['errors']
raise errors[0][1] unless errors.size == 0
cookies login.headers['set-cookie']
@modhash = login['json']['data']['modhash']
@username = username
- @userid = 't2_' + self.class.post('/api/me.json')['data']['id']
+ @userid = 't2_' + self.class.get('/api/me.json')['data']['id']
+ return login
end
# Logs out of a reddit account. This is usually uneeded, you can just log_in as a new account to replace the current one.
@@ -29,7 +31,7 @@ def log_out
#
# @note This method provides no verification or checking, so use with care
# @param password [String] The password of the reddit account
- # @return [HTTParty::Response] The httparty request object.
+ # @return (see #log_in)
def clear_sessions password
logged_in?
clear = self.class.post('/api/clear_sessions', body: { curpass: password, dest: @baseurl, uh: @modhash })

0 comments on commit 0c82a6b

Please sign in to comment.