Unverified login and dedicated route for verification email resend form

This commit is contained in:
fr33domlover 2018-03-17 22:59:40 +00:00
parent f196bf38d6
commit baeef7873e
3 changed files with 18 additions and 8 deletions

View file

@ -30,6 +30,9 @@ import Yesod.Core.Types (Logger)
import Yesod.Default.Util (addStaticContentExternal)
import Text.Email.Local
import Yesod.Auth.Unverified
import Yesod.Auth.Unverified.Creds
import Yesod.Mail.Send
import qualified Yesod.Core.Unsafe as Unsafe
@ -379,6 +382,8 @@ instance YesodAuth App where
authHttpManager = getHttpManager
onLogout = clearUnverifiedCreds False
instance YesodAuthPersist App
newtype AccountPersistDB' a = AccountPersistDB'
@ -436,13 +441,14 @@ instance AccountSendEmail App where
, url
]
instance YesodAuthVerify App where
verificationRoute _ = ResendVerifyEmailR
instance YesodAuthAccount AccountPersistDB' App where
runAccountDB = unAccountPersistDB'
--unregisteredLogin u = do
-- set creds unverified
--setUnverifiedCreds True $ Creds "account" (username u) []
-- redirect to resend form
-- ?
unregisteredLogin u = do
lift $ setUnverifiedCreds True $ Creds "account" (username u) []
return mempty
-- This instance is required to use forms. You can modify renderMessage to
-- achieve customized and internationalized form validation messages.

View file

@ -61,6 +61,10 @@
-- changes from yesod-auth 1.4.13.2, which is in LTS 6.5, to 1.6.2, which is
-- the latest release and where I copied from
-- * Instead of loginDest and onLogin, use my custom unverified counterparts
-- * Not call onLogout in clearUnverifiedCreds, because I use onLogout to clear
-- these creds, so it would either cause an infinite loop (if not
-- redirecting), or, if redirecting, the regular yesod-auth login session key
-- wouldn't get to be cleared
module Yesod.Auth.Unverified.Creds
( setUnverifiedCreds
, setUnverifiedCredsRedirect
@ -275,7 +279,7 @@ clearUnverifiedCreds :: YesodAuth master
-> HandlerT master IO ()
clearUnverifiedCreds doRedirects = do
y <- getYesod
onLogout
-- onLogout
deleteSession credsKey
when doRedirects $ do
redirectUltDest $ logoutDest y

View file

@ -38,9 +38,9 @@ class YesodAuth site => YesodAuthVerify site where
verificationRoute :: site -> Route site
-- | Default destination on successful unverified login, if no other
-- destination exists. Default: 'loginDest'
-- destination exists. Default: 'verificationRoute'
unverifiedLoginDest :: site -> Route site
unverifiedLoginDest = loginDest
unverifiedLoginDest = verificationRoute
-- | Called on a successful unverified login. Default: 'onLogin'
--onUnverifiedLogin :: (MonadHandler m, site ~ HandlerSite m) => m ()