Planning a simple Reddit clone with Yesod

The plan

The plan is to build a very simplified Reddit clone using Yesod. It will be my first real project using it (and Haskell too, actually), and I hope I will learn a lot from the process.

The users will be able to post URLs. Other users will be able to give a vote and add comments (no threads for now).

There will also be a simple profile page.

The end goal is to integrate some halogen widgets for advanced front-end functionalities.

Customizing the login page

My first goal is to find how to customize the login page. I want to prevent logged users from accessing the page and to change the allowed auth methods.

The second part is very easy: it’s enoguth to change the authPlugins entry in te YesodAuth App instance.

Preventing logged users from accessing the login page

The first part, luckily, is written as an example in Yesod’s source.

instance YesodAuth App where
  loginHandler = do
    ma <- lift maybeAuthId
    when (isJust ma) $
      lift $ redirect HomeR

As in the code above, it’s enough to implement the loginHandler method in the YesodAuth instance of the app (it’s defined in src/Foundation.hs).

Related Posts

Resizing and moving windows in Doom Emacs

Setting up TabNine on Doom Emacs

The correct docker-compose setup for Wordpress and Nginx

Adding a newline after a comment block in Doom Emacs

PureScript Date and Time guide

Adding live css and js reload to Yesod

A quick overview of Purescript package managers as of October 2018

Optional elements and properties in Halogen

Simple AJAX in Purescript

Automatically adding (or removing) a prefix to a record labels in Purescript