Reputation: 21
I'am writing a web app for personal use with Yesod. I don't want authentication and no log in. What is the best way to achieve this?
Upvotes: 1
Views: 118
Reputation: 50864
Assuming you're using a recent version of the scaffolded site, you should be able to look in src/Foundation.hs
for the definition of isAuthorized
. Replace the entire definition with:
isAuthorized _ _ = return Authorized
or even remove it entirely, since the above definition is the default.
That should be sufficient to allow access to all pages. Next, search your code for uses of maybeAuth*
and requireAuth*
functions. Make sure that pages that use maybeAuth*
work as expected if they get back Nothing
. Remove any uses of requireAuth*
and any dependencies on its return value.
Afterwards, you can clean up unneeded code, but this is entirely optional:
Foundation.hs
, you can:
Yesod.Auth.Dummy
and Yesod.Auth.OpenId
importsmuser <- maybeAuthPair
from defaultLayout
menuItems
)authRoute
definition in the instance Yesod App
AuthR
and ProfileR
from the breadcrumb
instance YesodAuth App
, the definition of isAuthenticated
, and the instance YesodAuthPersist App
NoFoundation.hs
, you can remove the Yesod.Auth
import.Settings.hs
, remove the appAuthDummyLogin
field and the reference to it in instance FromJSON AppSettings
config/routes.yesodroutes
remove /auth
and /profile
routessrc/Handler/Profile.hs
and the import Handler.Profile
from Application.hs
.maybeAuth*
functions or references to the ProfileR
route.Upvotes: 1