eidolon/Handler/Activate.hs

16 lines
410 B
Haskell
Raw Normal View History

2014-08-12 12:42:25 +00:00
module Handler.Activate where
import Import as I
getActivateR :: Text -> Handler Html
2014-08-12 12:42:25 +00:00
getActivateR token = do
2014-08-13 16:16:31 +00:00
t <- runDB $ selectFirst [TokenToken ==. token] []
2014-08-12 12:42:25 +00:00
case t of
2014-08-13 16:16:31 +00:00
Nothing -> do
2014-08-12 12:42:25 +00:00
setMessage $ [shamlet|<pre>Invalid Token!|]
redirect $ HomeR
2014-08-13 16:16:31 +00:00
Just x -> do
2014-08-12 12:42:25 +00:00
_ <- runDB $ insert $ tokenUser (entityVal x)
setMessage $ [shamlet|<pre>User activated|]
redirect $ HomeR