3
I have an authentication class that stores the user ID in a session, which receives the model name corresponding to the current user, for example: users, admins, clients.
Example:
Authentication.Guard("users").Attempt(user.id)
However, in this authentication class there is the method Get(), which must return the user data stored in the database through the model that receives as parameter the name of the Session guard_name and the value thereof.
public <guard_name> Get()
{
...
using (Entities db = new Entities())
{
return db.<guard_name>.Where(p => p.id == session)
.FirstOrDefault();
}
}
The problem is that as the name of Session guard_name can vary between users, admins and clients, I need a more dynamic return form or maybe use some interface.
How can I solve?