Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Automatically exchange token if it expires soon
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Hediard committed Jan 2, 2013
1 parent 8244549 commit 7c55e89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/groovy/grails/plugin/facebooksdk/FacebookContext.groovy
Expand Up @@ -90,6 +90,10 @@ class FacebookContext implements InitializingBean {
signedRequest = new FacebookSignedRequest(app.secret, cookie.value, FacebookSignedRequest.TYPE_COOKIE)
log.debug "Got signed request from cookie"
}
// Exchange token if it expires soon
if (authenticated && user.tokenLoaded && user.tokenExpiredSoon) {
user.exchangeToken()
}
}

boolean isAuthenticated() {
Expand Down
Expand Up @@ -187,6 +187,10 @@ class FacebookContextUser {
return expirationTime && (!isTokenExpired() && (expirationTime - new Date().time) < EXPIRATION_PREVENTION_THRESHOLD)
}

boolean isTokenLoaded() {
_token != null
}

String toString() {
"FacebookUser(id: $id)"
}
Expand Down

0 comments on commit 7c55e89

Please sign in to comment.