Git Product home page Git Product logo

Comments (5)

freebird-pass-consulting avatar freebird-pass-consulting commented on September 27, 2024

It is taken from the AccountsController.cs:
// output a <SCRIPT> tag to call a JS function registered into the parent window global scope return Content( "<script type'text/javascript'>" + "window.opener.externalProviderLogin(" + JsonConvert.SerializeObject(auth) + ");" + "window.close();" + "</script>", "text/html" );

The IE debugger shows this:
Unable to get property 'externalProviderLogin' of undefined or null reference

from aspdotnet-core-and-angular-2.

freebird-pass-consulting avatar freebird-pass-consulting commented on September 27, 2024

To be more precise, the authentication with the external provider (facebook in this case) succeeds but then there is a failure in the modal dailog. 'window.opener' is null for Internet Explorer so the javascript function 'externalProviderLogin does not get called and the modal window does not close.
All code has been updated to Angular 2 Version 4.0.0 and changes for Chapter 8 from Issue 3 have been applied.
I do not believe that this is a version 4.0.0 issue; I think that IE is just no supporting 'window.opener.'
Any workaround would be appreciated.
Thanks!

from aspdotnet-core-and-angular-2.

freebird-pass-consulting avatar freebird-pass-consulting commented on September 27, 2024

After fiddling with IE security settings I got a bit farther...
But now the code cannot access localStorage from auth.service.ts
` // Persist auth into localStorage or removes it if a NULL argument is given
setAuth(auth: any): boolean {
if (auth) {
localStorage.setItem(this.authKey, JSON.stringify(auth));
}
else {
localStorage.removeItem(this.authKey);
}
return true;
}

// Retrieves the auth JSON object (or NULL if none) 
getAuth(): any { 
    var i = localStorage.getItem(this.authKey); 
    if (i) { 
        return JSON.parse(i); 
    } 
    else { 
        return null; 
    } 
} `

from aspdotnet-core-and-angular-2.

freebird-pass-consulting avatar freebird-pass-consulting commented on September 27, 2024

After many attempts I found that in VS 2015 and IIS Express and IE 11 this line in Auth.Service.ts was failing:
`localStorage.setItem(this.authKey, JSON.stringify(auth));

JSON.stringify(auth) was returning NULL.

I replaced it with with this and it works:
localStorage.setItem(this.authKey, '{"type":"' + auth.type + '","providerName":"' + auth.providerName + '"}');

The setAuth method now looks like this:
` // Persist auth into localStorage or removes it if a NULL argument is given
setAuth(auth: any): boolean {

    if (auth) { 
        localStorage.setItem(this.authKey, '{"type":"' + auth.type + '","providerName":"' + auth.providerName + '"}'); 
    } 
    else { 
        localStorage.removeItem(this.authKey); 
    } 
    return true; 
} `

It also seems that IE needs to use Protected Mode enabled and www.facebook.com needs to be added as a trusted site.

A lot of minor details but it is now working!
:)

from aspdotnet-core-and-angular-2.

freebird-pass-consulting avatar freebird-pass-consulting commented on September 27, 2024

Add when getting to Chapter 9 I had to make this tweak...

` // Persist auth into localStorage or removes it if a NULL argument is given

setAuth(auth: any): boolean { 

    if (auth) { 

        if (auth.providerName)

            localStorage.setItem(this.authKey, '{"type":"' + auth.type + '","providerName":"' + auth.providerName + '"}');

        else

            localStorage.setItem(this.authKey, JSON.stringify(auth));

    } 

    else { 

        localStorage.removeItem(this.authKey); 

    } 

    return true; 

} `

from aspdotnet-core-and-angular-2.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.