title: Why does yesod require authorisation here?
body: <p>I have a problem with yesod and authorization.</p>
  
  <p>I get to the login page when trying to view blog posts when not logged in.</p>
  
  <p>That is not what I want.</p>
  
  <p>I want to be able to view blog posts even when not logged in.</p>
  
  <p>I have tried to fix it but nothing has worked.</p>
  
  <p>Here is the relevant sections of the code:</p>
  
  <pre><code>mkMessage "Blog" "messages" "en"
  
  mkYesod "Blog" [parseRoutes|
  / RootR GET
  /blog BlogR GET POST
  /blog/#EntryId EntryR GET POST
  /auth AuthR Auth getAuth
  |]
  
  instance Yesod Blog where
      approot = ApprootStatic "http://localhost:3000"
      defaultLayout = defLayout
      authRoute _ = Just $ AuthR LoginR
  
      isAuthorized BlogR True = do
        mauth &lt;- maybeAuth
        case mauth of
          Nothing -&gt; return AuthenticationRequired
          Just (Entity _ user)
               | isAdmin user -&gt; return Authorized
               | otherwise    -&gt; unauthorizedI MsgNotAnAdmin
  
      isAuthorized (EntryR _) True = do
        mauth &lt;- maybeAuth
        case mauth of 
           Nothing -&gt; return AuthenticationRequired
           Just _  -&gt; return Authorized
  
      isAuthorized _ _ = return Authorized
  
  isAdmin :: User -&gt; Bool
  isAdmin user = userEmail user == "email@something.com"
  
  instance YesodPersist Blog where
      type YesodPersistBackend Blog = SqlPersist
      runDB f = do
        master &lt;- getYesod
        let pool = connPool master
        runSqlPool f pool
  
  type Form x = Html -&gt; MForm Blog Blog (FormResult x, Widget)
  
  instance RenderMessage Blog FormMessage where
      renderMessage _ _ = defaultFormMessage
  
  instance YesodNic Blog
  
  instance YesodAuth Blog where
      type AuthId Blog = UserId
      loginDest _ = RootR
      logoutDest _ = RootR
      authHttpManager = httpManager
      authPlugins _ = [authBrowserId]
      getAuthId creds = do
        let email = credsIdent creds
            user = User email
        res &lt;- runDB $ insertBy user
        return $ Just $ either entityKey id res
  
  getRootR :: Handler RepHtml
  getRootR = defaultLayout $ do
               setTitleI MsgHomepageTitle
               [whamlet|
  &lt;p&gt;_{MsgWelcomeHomepage}
  &lt;p&gt;
      &lt;a href=@{BlogR}&gt;_{MsgSeeArchive}
  |]
  
  entryForm :: Form Entry
  entryForm = renderDivs $ Entry
              &lt;$&gt; areq textField (fieldSettingsLabel MsgNewEntryTitle) Nothing
              &lt;*&gt; aformM (liftIO getCurrentTime)
              &lt;*&gt; areq nicHtmlField (fieldSettingsLabel MsgNewEntryContent)
              Nothing
  
  getBlogR :: Handler RepHtml
  getBlogR = do
    muser &lt;- maybeAuth
    entries &lt;- runDB $ selectList [] [Desc EntryPosted]
    (entryWidget, enctype) &lt;- generateFormPost entryForm
    defaultLayout $ do
               setTitleI MsgBlogArchiveTitle
               [whamlet|
  $if null entries
      &lt;p&gt;_{MsgNoEntries}
  $else
      &lt;ul&gt;
          $forall Entity entryId entry &lt;- entries
              &lt;li&gt;
                  &lt;a href=@{EntryR entryId}&gt;#{entryTitle entry}
  $maybe Entity _ user &lt;- muser
      $if isAdmin user
          &lt;form method=post enctype=#{enctype}&gt;
                ^{entryWidget}
                &lt;div&gt;
                    &lt;input type=submit value=_{MsgNewEntry}&gt;
  $nothing
      &lt;p&gt;
          &lt;a href=@{AuthR LoginR}&gt;_{MsgLoginToPost}
  |]
  
  postBlogR :: Handler RepHtml
  postBlogR = do
    ((res, entryWidget), enctype) &lt;- runFormPost entryForm
    case res of
      FormSuccess entry -&gt; do
                entryId &lt;- runDB $ insert entry
                setMessageI $ MsgEntryCreated $ entryTitle entry
                redirect $ EntryR entryId
      _ -&gt; defaultLayout $ do
                setTitleI MsgPleaseCorrectEntry
                [whamlet|
  &lt;form method=post enctype=#{enctype}&gt;
      ^{entryWidget}
      &lt;div&gt;
          &lt;input type=submit value=_{MsgNewEntry}&gt;
  |]
  
  -- comment form
  commentForm         :: EntryId -&gt; Form Comment
  commentForm entryId = renderDivs $ Comment
                        &lt;$&gt; pure entryId
                        &lt;*&gt; aformM (liftIO getCurrentTime)
                        &lt;*&gt; aformM requireAuthId
                        &lt;*&gt; areq textField (fieldSettingsLabel MsgCommentName) Nothing
                        &lt;*&gt; areq textareaField (fieldSettingsLabel MsgCommentText) Nothing
  
  getEntryR :: EntryId -&gt; Handler RepHtml
  getEntryR entryId = do
    (entry, comments) &lt;- runDB $ do
            entry &lt;- get404 entryId
            comments &lt;- selectList [] [Asc CommentPosted]
            return (entry, map entityVal comments)
    muser &lt;- maybeAuth
    (commentWidget, enctype) &lt;- generateFormPost (commentForm entryId)
    defaultLayout $ do
      setTitleI $ MsgEntryTitle $ entryTitle entry
      [whamlet|
  &lt;h1&gt;#{entryTitle entry}
  &lt;article&gt;#{entryContent entry}
      &lt;section .comments&gt;
          &lt;h1&gt;_{MsgCommentsHeading}
          $if null comments
              &lt;p&gt;_{MsgNoComments}
          $else
               $forall Comment _entry posted _user name text &lt;- comments
                   &lt;div .comment&gt;
                        &lt;span .by&gt;#{name}
                        &lt;span .at&gt;#{show posted}
                        &lt;div .content&gt;#{text}
          &lt;section&gt;
              &lt;h1&gt;_{MsgAddCommentHeading}
              $maybe Entity _ user &lt;- muser
                  &lt;form method=post enctype=#{enctype}&gt;
                      ^{commentWidget}
                      &lt;div&gt;
                          &lt;input type=submit value=_{MsgAddCommentButton}&gt;
              $nothing
                  &lt;p&gt;
                      &lt;a href=@{AuthR LoginR}&gt;_{MsgLoginToComment}
  |]
  </code></pre>
  
  <p>How do i fix it?</p>