Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: b4168d1bd6
Fetching contributors…

Cannot retrieve contributors at this time

61 lines (37 sloc) 1.57 kB
package uk.co.desirableobjects.oauth.scribe
import org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException
import org.scribe.model.Token
class OauthTagLib {
static namespace = 'oauth'
OauthService oauthService
def connect = { attrs, body ->
String provider = attrs.provider
if (!provider) {
throw new GrailsTagException('No provider specified for <oauth:connect /> tag. Try <oauth:connect provider="your-provider-name" />')
}
Map a = attrs+[url:[controller:'oauth', action:'authenticate', params:[provider:provider]]]
out << g.link(a, body)
}
def connected = { attrs, body ->
String provider = attrs.provider
if (!provider) {
throw new GrailsTagException('No provider specified for <oauth:connected /> tag. Try <oauth:connected provider="your-provider-name" />')
}
String sessionKey = oauthService.findSessionKeyForAccessToken(provider)
Token oauthToken = session[sessionKey]
if (oauthToken) {
out << body()
}
}
def disconnected = { attrs, body ->
String provider = attrs.provider
if (!provider) {
throw new GrailsTagException('No provider specified for <oauth:disconnected /> tag. Try <oauth:disconnected provider="your-provider-name" />')
}
String sessionKey = oauthService.findSessionKeyForAccessToken(provider)
Token oauthToken = session[sessionKey]
if (!oauthToken) {
out << body()
}
}
}
Jump to Line
Something went wrong with that request. Please try again.