riverrun / phauxth

Not actively maintained - Authentication library for Phoenix, and other Plug-based, web applications
409 stars 21 forks source link

[FEATURE] Create 'Phauxth.Remember.Base' module #116

Closed michaeljones closed 4 years ago

michaeljones commented 4 years ago

Problem

I have used Phauxth but opted to split the user information in an account table (email & password) and a user table (display name & other details). I realise that this is a non-standard use case and therefore you shouldn't necessarily have to adjust to this.

It mostly worked well but I have found myself returning {user, account} from the get_by methods in accounts.ex. Unfortunately this errors when it hits the report helper in Phauxth.Authenticate.Base as used by Phauxth.Remember.

This is manageable for the report functions in Login, Confirm and Authenticate as I can create my own versions of those modules which use the Base implementations and then override the report functions but there isn't a Phauxth.Remember.Base module to do that with.

Solution

Move the contents of Phauxth.Remember into Phauxth.Remember.Base and have Phauxth.Remember use the Base version so that it is easier to create a custom Remember module that uses Phauxth.Remember.Base and overrides functions as needed.

Additional info

I am quite new to Elixir and Phoenix so I might be doing or saying a lot of things wrong. I apologise if I am wasting your time with this.

I've opted to split the tables into accounts & users because that seems to be a good approach for handling multiple different authentication methods for a user. I don't have anything other than email & password at the moment but I like the idea of being a bit more future proof. It is possible that if I'm serious about using multiple auth methods that I should choose a different auth library. I can understand that.

riverrun commented 4 years ago

Thanks for raising the issue. I will look into it and get back to you soon.

riverrun commented 4 years ago

Added an Authenticate.Remember module (instead of Remember.Base), so that the Remember module can be more easily customized.

This is in version 2.4.