New Posts New Posts RSS Feed: Need more info for LoginAsync
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Need more info for LoginAsync

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

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Topic: Need more info for LoginAsync
    Posted: 08-Mar-2011 at 4:32am
We are calling .LoginAsync and we have a simple login manager that simply creates a userbase with the credentials we pass in. It sets the name and isauthenticated=true. After the login is complete I expected that the EntityManager would then have a populated Principal but...well it does, but the name is null and isauthenticated is false.
 
So, after login:
EntityManager.IsLoggedIn = true
EntityManager.Principal.Identity.Name = null
EntityManager.Principla.Identity.IsAuthenticated = false
 

using System;
using System.Security.Principal;
using IdeaBlade.EntityModel;
using System.Runtime.Serialization;
namespace SilverlightApplication2
{
#if !SILVERLIGHT
    public class SimpleLoginManager : IEntityLoginManager
    {
    #region IEntityLoginManager Members
        public IPrincipal Login(ILoginCredential credential, EntityManager entityManager)
        {
            return new UserBase(new GenericIdentity(credential.UserName), null);
        }
        public void Logout(IPrincipal principal, EntityManager entityManager)
        {
        }
        #endregion
    }
#endif
    [DataContract]
    public class GenericIdentity : IIdentity
    {
        #region IIdentity Members
        public GenericIdentity(string name)
        {
            Name = name;
            IsAuthenticated = true;
        }
        public string AuthenticationType
        {
            get;
            internal set;
        }
        public bool IsAuthenticated
        {
            get;
            internal set;
        }
        public string Name
        {
            get;
            internal set;
        }
        #endregion
    }
}
 
So, what am I doing wrong or how are my expectations wrong?
What I want to end up with is a correctly populated Identity on the EntityManager if possible.
(I know this example doesn't handle null, its just for testing upcoming changes)
 
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 08-Mar-2011 at 8:10am
I think the problem is in the GenericIdentity.  You've marked the type as a DataContract, but haven't marked any DataMembers, so the type is serialized/deserialized OK, but with default values.
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 08-Mar-2011 at 8:47am
Wow, thats embarrassing.
 
Thank you.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down