What's Wrong With This Picture

3 posts, 0 answers
  1. Kelly
    Kelly avatar
    73 posts
    Member since:
    Apr 2011

    Posted 12 Mar 2014 Link to this post

    Hello,

    It was my understanding that User records guaranteed a unique email address.  In the attached pic, I obscured my test name and email, but I assure you that the records are identical in every way, except for the Id and Owner fields.  The Identity details are also identical.  If I try to add the email address again through the TBS data browser, I get the error one would expect.

    Let me know if I could be doing something wrong.  All I did was call LoginWithLiveID passing a valid token returned from Windows Live.  Obviously, my call to Windows Live was correct, because TBS was able to get my email address.  I don't know what else I could have done to cause this situation. 

    I don't know if the duplicate was created as a result of my first login using LiveID, or from my second login, because  I didn't notice it until after my second attempt.  I noticed in the detail that the "updated_time" in the Identity info is the same, so I'm assuming both records were created in one call.  I have called the same code several times now, and am able to login successfully to TBS using Windows Live each time.  No more records have been created.

    Thanks,

    Kelly
  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 13 Mar 2014 Link to this post

    Hello Kelly,

    Could you please share the code used for the registration?

    A possible assumption for the cause of this behavior is that two requests were sent to the server simultaneously. This could be related to some event handlers registered in the code.

    In addition, you could check the latest version of our hybrid sample here.

    Let us know if this works for you.

    Regards,
    Anton Dobrev
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform. For more information on the new name, and to learn more about the Platform, register for the free online keynote and webinar on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT)
     
  3. Kelly
    Kelly avatar
    73 posts
    Member since:
    Apr 2011

    Posted 13 Mar 2014 in reply to Anton Dobrev Link to this post

    Hi Anton:

    The code is pretty much cut-and-pasted from the latest Friends app, although, naturally, my client id is changed.  Here is the code, which is called from the tap handler for a touch object. The "flash" call does nothing but toggle the background of a li element for a few ms for visual feedback.  The identity-provider code is taken from the sample without changes.  I also added email scope to the request:

    var loginWindows = function (e) {
        app.logins.flash(e.sender.element);
        app.notifyapp.showLoading();
         
        var liveIdConfig = {
            name: 'LiveID',
            loginMethodName: 'loginWithLiveID',
            response_type: 'token',
            client_id: appkeys.liveId.clientId,
            redirect_uri: appkeys.liveId.redirectUri,
            scope: 'wl.basic,wl.emails',
            access_type: 'online',
            display: 'touch'
        };
         
        var liveId = new IdentityProvider(liveIdConfig);
         
        liveId.getAccessToken( function(token) {
             
            app.everlive.Users.loginWithLiveID(token)
             
            .then(function () {
                return app.User.load();
            })
             
            .then(function () {
                app.notifyapp.navigate('views/nextView.html');
                app.notifyapp.hideLoading();
            })
     
            .then(null, function (err) {
                app.notifyapp.hideLoading();
                alert(err.message);
            });
        });
    };

    Regarding the simultaneity of requests, the first time I tried this code in the simulator, I forgot to put in the call that navigates away from the login page.  I remember executing the login once, then initiating the same call a few seconds after the first login sequence ended - I expected the code to navigate away from the page, and when it didn't I probably clicked on my Login button again just for the hell of it to see if the page was hung.  It would have been 10 or 15 seconds later, though, as I'm sure you know this oauth login stuff is slow slow slow.  The bottom line - I know I did a LiveID login using the everlive.Users object that was already logged in via LiveID.  But the two logins would have been separated by several seconds.

    As for the sample, that's the code I patterned this after - it certainly works!!  I think we need to slow it down it works so well, ha ha.

    At first, I thought my application was dead in the water as far as TBS is concerned, because it depends on a unique email address.  But what I found is that the subsequent logins still work just fine, and everything I need is still returned correctly by the currentUser call.  The duplicate record doesn't seem to confuse the server, so it has no net effect on my app. either.  This has the feel of one of those things I couldn't reproduce even if I tried, so I'm not going to worry about it unless it becomes a problem.  Thanks for looking into it - you're the best.

    Kelly
Back to Top