Comments (5)
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.
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.
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.
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.
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)
- Code won't compile because of some typescript error HOT 9
- Chapter 6: ng2-bootstrap TypeError HOT 2
- Loading all js libraries on initial load HOT 1
- OpenIddict refresh required on VS2017 code HOT 2
- Reference issues working the example with latest preview tools and versions of TS and Angular HOT 1
- OpenIddict v1.0.0-beta1-0481 - No longer supports OpenIddictUser HOT 7
- post script typings install doesn't work HOT 2
- Can't login after password changing. HOT 1
- Does not build & run using latest version of .net HOT 2
- Stuck on "Loading..." HOT 1
- Bad request with authservice.get() HOT 1
- user.identity.isauthenticated always false ??? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aspdotnet-core-and-angular-2.