Ejemplo n.º 1
0
        public void RegisterUser(JsonObject ps)
        {
            Profile p = new Profile();

            ProfileManager pm = new ProfileManager();

            FacebookService fb = new FacebookService();
            Facebook.JsonObject o = fb.DownloadData<Facebook.JsonObject>("/me", ps["accessToken"].ToString());

            if (pm.LoadUser(o["email"].ToString()) != null)
                throw new Exception("Profile already exists");

            p.CreationDate = DateTime.Now;
            p.Email = o["email"].ToString();
            p.IsLockedOut = false;

            if (o.ContainsKey("username"))
                p.UserName = o["username"].ToString();
            else
                p.UserName = ps["userID"].ToString();

            pm.RegisterUser(p);

            SocialConnection sc = new SocialConnection();
            sc.OauthToken = ps["accessToken"].ToString();
            sc.ReferenceID = ps["userID"].ToString();
            sc.ServiceID = SocialServiceType.Facebook;
            sc.UserID = p.UserID;

            SocialServiceManager scm = new SocialServiceManager();
            scm.AddConnection(sc);

            pm.ReleaseAuthenticationTicket(p);
        }
Ejemplo n.º 2
0
        public bool CheckLogin(JsonObject ps)
        {
            FacebookService fb = new FacebookService();
            Facebook.JsonObject o = fb.DownloadData<Facebook.JsonObject>("/me", ps["accessToken"].ToString());

            ProfileManager pm = new ProfileManager();
            Profile p = pm.LoadUser(o["email"].ToString());

            if (p != null)
            {
                pm.ReleaseAuthenticationTicket(p);
                return true;
            }
            else
                return false;
        }