yesod-auth-zendesk-1.2: Zendesk remote authentication support for Yesod apps.

Safe HaskellNone




class YesodAuthPersist site => YesodZendesk site whereSource

Type class that you need to implement in order to support Zendesk remote authentication.

Minimal complete definition: all functions are required.


zendeskToken :: site -> ByteStringSource

Shared secret between Zendesk and your site.

zendeskAuthURL :: site -> TextSource

URL on your Zendesk's site where users should be redirected to when logging in.

zendeskUserInfo :: HandlerT site IO ZendeskUserSource

Gather information that should be given to Zendesk about an user. Please see ZendeskUser for more information about what these fields mean.

Simple example:

 zendeskUserInfo = do
   Entity uid user <- requireAuth
   return def { zuName  = userName user
              , zuEmail = userEmail user }

Advanced example:

 zendeskUserInfo = do
   uid <- requireAuthId
   render <- getUrlRender
   runDB $ do
     Just user <- get uid
     Just org  <- get (userOrganization user)
     return def { zuName           = userName user
                , zuEmail          = userEmail user
                , zuOrganization   = Just (organizationName org)
                , zuRemotePhotoURL = Just (render $ UserPhotoR uid)

Note: although I don't recomend this and I don't see any reason why you would do it, it is possible to use maybeAuth instead of requireAuth and login on Zendesk with some sort of guest user should the user not be logged in.

data ZendeskUser Source

Information about a user that is given to Zendesk. Please see Zendesk's documentation ( in order to see more details of how theses fields are interpreted.

Only zuName and zuEmail are required.




zuName :: Text

User name, at least two characters. (required)

zuEmail :: Text

E-mail address. (required)

zuExternalId :: ZendeskExternalId

An external (to Zendesk) ID that identifies this user. Defaults to UseYesodAuthId.

zuOrganization :: Maybe Text

Organization the user belongs to.

zuTags :: [Text]

List of tags.

zuRemotePhotoURL :: Maybe Text

Public URL with the user's profile picture.


data ZendeskExternalId Source

Which external ID should be given to Zendesk.



Use the user ID from persistent's database. This is the recommended and default value.

Explicit Text

Use this given value.


Do not give an external ID.

data Zendesk Source

Data type for yesod-auth-zendesk's subsite.

getZendesk :: a -> ZendeskSource

Create a new Zendesk, use this on your config/routes file.

zendeskLoginRoute :: Route ZendeskSource

Redirect the user to Zendesk such that they're already logged in when they arrive. For example, you may use zendeskLoginRoute when the user clicks on a "Support" item on a menu.