Safe Haskell | None |
---|
- class YesodAuthPersist master => YesodDeskCom master where
- deskComCredentials :: master -> DeskComCredentials
- deskComUserInfo :: AuthId master -> HandlerT master IO DeskComUser
- deskComTokenTimeout :: master -> NominalDiffTime
- deskComCreateCreds :: Text -> Text -> Text -> DeskComCredentials
- data DeskComCredentials
- data DeskComUser = DeskComUser {}
- data DeskComUserId
- type DeskComCustomField = (Text, Text)
- data DeskCom
- initDeskCom :: IO DeskCom
- deskComLoginRoute :: Route DeskCom
- deskComMaybeLoginRoute :: Route DeskCom
Documentation
class YesodAuthPersist master => YesodDeskCom master whereSource
Type class that you need to implement in order to support Desk.com remote authentication.
Minimal complete definition: everything except for deskComTokenTimeout
.
deskComCredentials :: master -> DeskComCredentialsSource
The credentials needed to use Multipass. Use
deskComCreateCreds
. We recommend caching the resulting
DeskComCredentials
value on your foundation data type
since creating it is an expensive operation.
deskComUserInfo :: AuthId master -> HandlerT master IO DeskComUserSource
Gather information that should be given to Desk.com about
an user. Please see DeskComUser
for more information
about what these fields mean.
Simple example:
deskComUserInfo uid = do user <- runDB $ get uid returndef
{duName
= userName user ,duEmail
= userEmail user }
Advanced example:
deskComUserInfo uid = do render <-getUrlRender
runDB $ do Just user <- get uid Just org <- get (userOrganization user) returndef
{duName
= userName user ,duEmail
= userEmail user ,duOrganization
= Just (organizationName org) ,duRemotePhotoURL
= 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 Desk.com
with some sort of guest user should the user not be logged
in.
deskComTokenTimeout :: master -> NominalDiffTimeSource
Each time we login an user on Desk.com, we create a token. This function defines how much time the token should be valid before expiring. Should be greater than 0. Defaults to 5 minutes.
:: Text | The name of your site (e.g., |
-> Text | The domain of your site
(e.g. |
-> Text | The Multipass API key, a shared secret between Desk.com and your site. |
-> DeskComCredentials |
Create the credentials data type used by this library. This function is relatively expensive (uses SHA1 and AES), so you'll probably want to cache its result.
data DeskComCredentials Source
Credentials used to access your Desk.com's Multipass.
data DeskComUser Source
Information about a user that is given to DeskCom
. Please
see Desk.com's documentation
(http://dev.desk.com/docs/portal/multipass) in order to see
more details of how theses fields are interpreted.
DeskComUser | |
|
Eq DeskComUser | |
Ord DeskComUser | |
Read DeskComUser | |
Show DeskComUser | |
Default DeskComUser | Fields |
data DeskComUserId Source
Which external ID should be given to Desk.com.
UseYesodAuthId | Use the user ID from |
Explicit Text | Use this given value. |
type DeskComCustomField = (Text, Text)Source
The value of a custom customer field as (key, value)
.
Note that you have prefix your key
with "custom_"
.
Data type for yesod-auth-deskCom
's subsite.
RouteAttrs DeskCom | |
ParseRoute DeskCom | |
RenderRoute DeskCom | |
YesodDeskCom master => YesodSubDispatch DeskCom (HandlerT master IO) | |
Eq (Route DeskCom) | |
Read (Route DeskCom) | |
Show (Route DeskCom) |
initDeskCom :: IO DeskComSource
Initialize the DeskCom
subsite with a fresh CPRNG.
deskComLoginRoute :: Route DeskComSource
Redirect the user to Desk.com such that they're already
logged in when they arrive. For example, you may use
deskComLoginRoute
as the login URL on Multipass config.
deskComMaybeLoginRoute :: Route DeskComSource
If the user is logged in, redirect them to Desk.com such
that they're already logged in when they arrive (same as
deskComLoginRoute
). Otherwise, redirect them to Desk.com
without asking for credentials. For example, you may use
deskComMaybeLoginRoute
when the user clicks on a "Support"
item on a menu.