yesodweb/yesod — pull request #760 by 2piix (2014-06-16 19:20:12+00:00)
Title: Make requireAuth and requireAuthId class methods for YesodAuth class

As an effort to be more constructive, I am making this pull request.

The idea is to create a simple "entry point" for users of the Auth system.

Thesis: If we think of `requireAuth` in declarative terms, it should be saying "the user needs to be authenticated to run this Handler." In other words, it should work like something of a guard for the Handler it gets used in.

Moving `requireAuth` to the `YesodAuth` type class gives us some flexibility. Instead of each Yesod-using-developer having to make a class like:

class YesodAuth master => MyAuth master where
requireAuthentication :: Handler (AuthId master)

in order add "arbitrary" (site specific) requirements, we can just override the default method in the YesodAuth class.

The name `requireAuth` is too good for the framework to take it, and not allow customization.