getVerifyR :: UserId -> Text -> Handler RepHtml
getVerifyR userId verKey = do
    mCurrUser <- currentUser
    success <- case mCurrUser of
        -- Skip if logged in.
        Just _ -> return False
        Nothing -> do
            mUser <- runDB $ getBy $ UniqueUserEmailVer userId
            case mUser of
                -- Skip nonexistant users.
                Nothing -> return False
                Just (Entity evId (EmailVerification _ correctVerKey)) ->
                    -- Keys don't match.
                    if (verKey /= correctVerKey) then return False
                    -- Verify and login if keys match.
                    else do
                        runDB $ do
                            update userId [UserVerified =. True]
                            delete evId
                        doLogin userId
                        return True
    if success
        then do
            setSession "_orderSuccess" "You have been successfully verified. \                   \Welcome to Bannerstalker!"
            redirect AccountR
        else redirect AccountR
getVerifyR :: UserId -> Text -> Handler RepHtml
getVerifyR userId verKey = do
    mCurrUser <- currentUser
    success <- case mCurrUser of
        -- Skip if logged in.
        Just _ -> return False
        Nothing -> do
            mUser <- runDB $ getBy $ UniqueUserEmailVer userId
            case mUser of
                -- Skip nonexistant users.
                Nothing -> return False
                Just (Entity evId (EmailVerification _ correctVerKey)) ->
                    -- Keys don't match.
                    if (verKey /= correctVerKey) then return False
                    -- Verify and login if keys match.
                    else do
                        runDB $ do
                            update userId [UserVerified =. True]
                            delete evId
                        doLogin userId
                        return True
    if success
        then do
            setSession "_orderSuccess" "You have been successfully verified. \                   \Welcome to Bannerstalker!"
            redirect AccountR
        else redirect AccountR
getVerifyR userId verKey = do
    mCurrUser <- currentUser
    success <- case mCurrUser of
        -- Skip if logged in.
        Just _ -> return False
        Nothing -> do
            mUser <- runDB $ getBy $ UniqueUserEmailVer userId
            case mUser of
                -- Skip nonexistant users.
                Nothing -> return False
                Just (Entity evId (EmailVerification _ correctVerKey)) ->
                    -- Keys don't match.
                    if (verKey /= correctVerKey) then return False
                    -- Verify and login if keys match.
                    else do
                        runDB $ do
                            update userId [UserVerified =. True]
                            delete evId
                        doLogin userId
                        return True
    if success
        then do
            setSession "_orderSuccess" "You have been successfully verified. \                   \Welcome to Bannerstalker!"
            redirect AccountR
        else redirect AccountR