yesod / yesod-auth / auth2
2012-03-19 11:36
155 查看
mkPersist[$persist|
emailStringEq
statusBoolupdate
verkeyStringnullupdate
passwordStringnullupdate
UniqueEmailemail
|]
dataA2=A2{connPool::ConnectionPool}
mkYesod"A2"[$parseRoutes|
/authAuthRAuthgetAuth
|]
instanceYesodA2whereapproot_="http://localhost:3000"
instanceYesodAuthA2where
typeAuthIdA2=String
loginDest_=AuthRCheckR
logoutDest_=AuthRCheckR
getAuthId=return.Just.credsIdent
showAuthId=constid
readAuthId=constJust
authPlugins=
[authDummy
,authOpenId
,authRpxnow"yesod-test""c8043882f14387d7ad8dfc99a1a8dab2e028f690"
,authFacebook
"d790dfc0203e31c0209ed32f90782c31"
"a7685e10c8977f5435e599aaf1d232eb"
[]
,authEmail
]
main::IO()
main=withConnectionPool$\p->do
fliprunConnectionPoolp$runMigration$migrate(undefined::Email)
basicHandler3000$A2p
instanceYesodAuthEmailA2where
typeAuthEmailIdA2=EmailId
showAuthEmailId_=show
readAuthEmailId_=readMay
addUnverifiedemailverkey=runDB$insert$EmailemailFalse(Justverkey)Nothing
sendVerifyEmailemailverkeyverurl=do
render<-getUrlRenderParams
tm<-getRouteToMaster
letlbs=renderHamletrender[$hamlet|
%p
%a!href=$verurl$Verifyyouremailaddress.
|]
liftIO$renderSendMailMail
{mailHeaders=
[("To",email)
,("From","reply@orangeroster.com")
,("Subject","OrangeRoster:Verifyyouremailaddress")
]
,mailPlain=verurl
,mailParts=
[Part
{partType="text/html;charset=utf-8"
,partEncoding=None
,partDisposition=Inline
,partContent=lbs
}
]
}
getVerifyKeyemailid=runDB$do
x<-get$fromIntegralemailid
return$maybeNothingemailVerkeyx
setVerifyKeyemailidverkey=runDB$
update(fromIntegralemailid)[EmailVerkey$Justverkey]
verifyAccountemailid'=runDB$do
letemailid=fromIntegralemailid'
x<-getemailid
uid<-
casexof
Nothing->returnNothing
Justemail->do
updateemailid[EmailStatusTrue]
return$Just$emailEmailemail
returnuid
getPasswordemail=runDB$do
x<-getBy$UniqueEmailemail
return$x>>=emailPassword.snd
setPasswordemailpassword=runDB$
updateWhere[EmailEmailEqemail][EmailPassword$Justpassword]
getEmailCredsemail=runDB$do
x<-getBy$UniqueEmailemail
casexof
Nothing->returnNothing
Just(eid,e)->
return$JustEmailCreds
{emailCredsId=fromIntegraleid
,emailCredsAuthId=Just$emailEmaile
,emailCredsStatus=emailStatuse
,emailCredsVerkey=emailVerkeye
}
getEmailemailid=runDB$do
x<-get$fromIntegralemailid
return$fmapemailEmailx
instanceYesodPersistA2where
typeYesodDBA2=SqlPersist
runDBdb=fmapconnPoolgetYesod>>=runConnectionPooldb
withConnectionPool::MonadCatchIOm=>(ConnectionPool->ma)->ma
withConnectionPool=withSqlitePool"auth2.db3"10
runConnectionPool::MonadCatchIOm=>SqlPersistma->ConnectionPool->ma
runConnectionPool=runSqlPool
相关文章推荐
- yesod / yesod-auth / browserid
- yesod / yesod-auth / Yesod / Auth
- yesod / yesod-core / widget-benchmark
- Haskell的yesod框架-1
- Yesod - 简介 (0)
- Yesod is a Haskell web framework
- Haskell的Yesod技术大全
- Yesod - Haskell (1)
- Yesod - 基础结构 (2)
- Yesod - 组件 (4)
- Yesod - 类型类 (5)
- Yesod - 路由和响应 (6)
- yesod / yesod-auth-oauth
- Yesod - 数据库 (9)
- yesod / yesod-auth / openid
- 系统分析与架构设计的随想与面向集合的分析设计思想(SOA & SOD)
- sod
- SODBASE CEP学习(一):SODBASE CEP简介
- SODBASE CEP学习进阶篇(三):自己写输入输出适配器
- csdn git code 不能git clone git@code.csdn.net:yefengxuelang/testcsdn.git