Skip to content

Instantly share code, notes, and snippets.

@probablycorey
Created February 8, 2011 21:22
Show Gist options
  • Select an option

  • Save probablycorey/817276 to your computer and use it in GitHub Desktop.

Select an option

Save probablycorey/817276 to your computer and use it in GitHub Desktop.
test.lua
waxClass{"User", Base}
-- Class Methods
----------------
function login(class, login, password)
class:get{class:url("user/show/%s", login), callback = function(body, response)
puts(body)
end,
authCallback = function(challenge)
if challenge:previousFailureCount() == 0 and not challenge:proposedCredential() then
local credential = NSURLCredential:credentialWithUser_password_persistence(login, password, NSURLCredentialPersistenceNone)
challenge:sender():useCredential_forAuthenticationChallenge(credential, challenge)
else
challenge:sender():continueWithoutCredentialForAuthenticationChallenge(challenge)
end
end}
end
function currentUser(class)
return wax.cache.get("current-user")
end
function setCurrentUser(class, user)
return wax.cache.set("current-user", user)
end
-- Instance Methods
-------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment