{-# LANGUAGE TupleSections, OverloadedStrings #-} module Handler.Signup where import Import as I import System.Random import Data.Text as T import Network.Mail.Mime import Text.Blaze.Html.Renderer.Utf8 getSignupR :: Handler Html getSignupR = do (signupWidget, enctype) <- generateFormPost signupForm defaultLayout $ do $(widgetFile "signup") postSignupR :: Handler Html postSignupR = do ((result, signupWidget), enctype) <- runFormPost signupForm case result of FormSuccess user -> do namesakes <- runDB $ selectList [UserName ==. (userName user)] [] case (validateLen (userName user)) && ((I.length namesakes) == 0) of True -> do tokenString <- liftIO generateString uId <- runDB $ insert $ Token tokenString user activateLink <- ($ ActivateR tokenString) <$> getUrlRender sendMail (userEmail user) "Please activate your account!" $ [shamlet|