Reputation: 1115
I've been learning Yesod by using it to rebuild my website. I started off using the code generated by yesod init
. This code uses the authentication framework that comes with Yesod, including Yesod.Auth.Email, which allows you to create an account by providing an email address.
The problem I have with the default code is this: it sets the user identifier to their email address. If the identifier is going to be used publicly on the website (e.g. to identify commentators on a page / blog) then you need something which the user won't mind being displayed to identify them.
Ideally, I want the website to ask for a (unique) public identifier either at the point when they submit their email address, or when they click the link to validate the account and type in their password. The problem is that this would appear to require changes to Yesod modules, since the register / password forms are defined there.
I can make the changes easily enough. But I don't really want to keep forking Yesod modules to make them do what I want them to do. Is there another way to do this using the existing yesod-auth modules? It's entirely possible that this can be done with the framework as it is, but if so a small example would be appreciated.
Upvotes: 3
Views: 356
Reputation: 851
I'm not sure what code you're using to show the user's identity on the website but you could very easily add a column to the user table:
User
...
publicIdentifier Text Update
and in your hamlet just interpolate the variable:
#{userPublicIdentifier user}
Upvotes: 1