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