New Posts New Posts RSS Feed: Using entitymanager while authenticating
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Using entitymanager while authenticating

 Post Reply Post Reply
Author
pponzano View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Apr-2011
Location: Italy
Posts: 165
Post Options Post Options   Quote pponzano Quote  Post ReplyReply Direct Link To This Post Topic: Using entitymanager while authenticating
    Posted: 02-Oct-2012 at 8:45am
Hello,
in my LoginManager I'm tring to verify if the user passoword has expired

I do so

  protected override bool ValidateUserCore(ILoginCredential credential)
        {
            bool res = base.ValidateUserCore(credential);

            //if (res)
            //{
            //    //Verifico che non sia scaduta la password

               
            //    EntityManager.ExecuteQuery();

            //    myModelContainer container = new myModelContainer(new EntityManagerContext(true));

            //    var user = container.aspnet_Users.FirstOrDefault(o1 => o1.UserName == credential.UserName);

            //    if (user != null)
            //    {
            //        DateTime expiryDate = DateTime.Now;
            //        if (user.USER_ACCOUNT_EXPIRY != null)
            //        {
            //            expiryDate = user.USER_ACCOUNT_EXPIRY.DATA_SCADENZA.Value;
            //        }

            //        if (expiryDate < DateTime.Now)
            //        {
            //            throw new ExpiredLoginException(expiryDate);
            //        }
            //    }

            //}

            return res;
        }

But I got an exception since the EntityManager is not authenticated, since I need to have the guest account disabled and I'm on the server during the login phase, what can I do to have access to my table?
Thanks
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 02-Oct-2012 at 11:20am
Hi,
 
I'd suggest to enable guest users and use QueryInterceptor to only allow specific entities to be accessed by these guest users.
 
sbelini.
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 05-Oct-2012 at 11:37am
In addition if you actually use the EntityManager from the LoginManager, you will be able to execute queries.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down