How can i show the data in angular component after authentication is done in a Pop up window?
I have to do the authentication in angular by GitLab. So i have created a button in my angular-app. After click on that button this function will be call the login() which will open a pop up. After log in successfully i got the access token by which i will get the data from GitLab.
isLoggedIn = true;
api: any;
public test: any;
accessToken: any;
constructor(
private router: Router,
private route: ActivatedRoute,
private gitLabApi: GitLabApiService,
private cd: ChangeDetectorRef
)
ngOnInit()
this.accessToken = localStorage.getItem('access_token');
if (this.accessToken)
this.apiRequest();
else
logOut()
if (this.accessToken)
console.log(localStorage.removeItem('access_token'));
this.isLoggedIn = false;
this.router.navigate(['logginIn']);
this.sideBar.afterLogIn = false;
apiRequest()
this.gitLabApi.getProjectApi(this.accessToken).subscribe(
apiData =>
this.api = apiData;
// console.log(this.api);
this.cd.markForCheck();
this.isLoggedIn = true;
,
error => console.log(error.message)
);
this.sideBar.getCommitDetail();
this.sideBar.afterLogIn = true;
logIn()
//window.location.href = authUrl;
window.open(authUrl, "pop Up", "width=250, height= 250 ")
But after closing the pop up in ngOnInit, its not redirect to my page.
Instead of window.open
if i use window.location.href
then its working fine. Now how can i achieve the same functionality with window.open
?
angular
add a comment |
I have to do the authentication in angular by GitLab. So i have created a button in my angular-app. After click on that button this function will be call the login() which will open a pop up. After log in successfully i got the access token by which i will get the data from GitLab.
isLoggedIn = true;
api: any;
public test: any;
accessToken: any;
constructor(
private router: Router,
private route: ActivatedRoute,
private gitLabApi: GitLabApiService,
private cd: ChangeDetectorRef
)
ngOnInit()
this.accessToken = localStorage.getItem('access_token');
if (this.accessToken)
this.apiRequest();
else
logOut()
if (this.accessToken)
console.log(localStorage.removeItem('access_token'));
this.isLoggedIn = false;
this.router.navigate(['logginIn']);
this.sideBar.afterLogIn = false;
apiRequest()
this.gitLabApi.getProjectApi(this.accessToken).subscribe(
apiData =>
this.api = apiData;
// console.log(this.api);
this.cd.markForCheck();
this.isLoggedIn = true;
,
error => console.log(error.message)
);
this.sideBar.getCommitDetail();
this.sideBar.afterLogIn = true;
logIn()
//window.location.href = authUrl;
window.open(authUrl, "pop Up", "width=250, height= 250 ")
But after closing the pop up in ngOnInit, its not redirect to my page.
Instead of window.open
if i use window.location.href
then its working fine. Now how can i achieve the same functionality with window.open
?
angular
add a comment |
I have to do the authentication in angular by GitLab. So i have created a button in my angular-app. After click on that button this function will be call the login() which will open a pop up. After log in successfully i got the access token by which i will get the data from GitLab.
isLoggedIn = true;
api: any;
public test: any;
accessToken: any;
constructor(
private router: Router,
private route: ActivatedRoute,
private gitLabApi: GitLabApiService,
private cd: ChangeDetectorRef
)
ngOnInit()
this.accessToken = localStorage.getItem('access_token');
if (this.accessToken)
this.apiRequest();
else
logOut()
if (this.accessToken)
console.log(localStorage.removeItem('access_token'));
this.isLoggedIn = false;
this.router.navigate(['logginIn']);
this.sideBar.afterLogIn = false;
apiRequest()
this.gitLabApi.getProjectApi(this.accessToken).subscribe(
apiData =>
this.api = apiData;
// console.log(this.api);
this.cd.markForCheck();
this.isLoggedIn = true;
,
error => console.log(error.message)
);
this.sideBar.getCommitDetail();
this.sideBar.afterLogIn = true;
logIn()
//window.location.href = authUrl;
window.open(authUrl, "pop Up", "width=250, height= 250 ")
But after closing the pop up in ngOnInit, its not redirect to my page.
Instead of window.open
if i use window.location.href
then its working fine. Now how can i achieve the same functionality with window.open
?
angular
I have to do the authentication in angular by GitLab. So i have created a button in my angular-app. After click on that button this function will be call the login() which will open a pop up. After log in successfully i got the access token by which i will get the data from GitLab.
isLoggedIn = true;
api: any;
public test: any;
accessToken: any;
constructor(
private router: Router,
private route: ActivatedRoute,
private gitLabApi: GitLabApiService,
private cd: ChangeDetectorRef
)
ngOnInit()
this.accessToken = localStorage.getItem('access_token');
if (this.accessToken)
this.apiRequest();
else
logOut()
if (this.accessToken)
console.log(localStorage.removeItem('access_token'));
this.isLoggedIn = false;
this.router.navigate(['logginIn']);
this.sideBar.afterLogIn = false;
apiRequest()
this.gitLabApi.getProjectApi(this.accessToken).subscribe(
apiData =>
this.api = apiData;
// console.log(this.api);
this.cd.markForCheck();
this.isLoggedIn = true;
,
error => console.log(error.message)
);
this.sideBar.getCommitDetail();
this.sideBar.afterLogIn = true;
logIn()
//window.location.href = authUrl;
window.open(authUrl, "pop Up", "width=250, height= 250 ")
But after closing the pop up in ngOnInit, its not redirect to my page.
Instead of window.open
if i use window.location.href
then its working fine. Now how can i achieve the same functionality with window.open
?
angular
angular
asked Nov 13 '18 at 13:06
KaziKazi
102111
102111
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
you can check this ng-bootstrap
actually i am not looking any css. I want to do the authentication in my pop up window. Here nothing to do with the css i guess
– Kazi
Nov 13 '18 at 13:16
add a comment |
The issue is that window.close
is closing the window which the router then tries to navigate. You need the logIn method to handle the routing logic for the original instance of the app once the login window is closed. Example:
logIn()
const newwindow = window.open(authUrl, "pop Up", "width=250, height= 250 ");
newwindow.onbeforeunload = () =>
if (localStorage.getItem('access_token'))
this.router.navigate(['manager']);
this.apiRequest();
else
// login failed
hi unfortunently its not working. Before windows is closing or user logged in, ` newwindow.onbeforeunload = () => if (localStorage.getItem('access_token')) this.router.navigate(['manager']); this.apiRequest(); else // login failed ` this line of code is executing. @teddy-sterne
– Kazi
Nov 13 '18 at 13:49
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53281680%2fhow-can-i-show-the-data-in-angular-component-after-authentication-is-done-in-a-p%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
you can check this ng-bootstrap
actually i am not looking any css. I want to do the authentication in my pop up window. Here nothing to do with the css i guess
– Kazi
Nov 13 '18 at 13:16
add a comment |
you can check this ng-bootstrap
actually i am not looking any css. I want to do the authentication in my pop up window. Here nothing to do with the css i guess
– Kazi
Nov 13 '18 at 13:16
add a comment |
you can check this ng-bootstrap
you can check this ng-bootstrap
answered Nov 13 '18 at 13:12
Skandar B.ASkandar B.A
214
214
actually i am not looking any css. I want to do the authentication in my pop up window. Here nothing to do with the css i guess
– Kazi
Nov 13 '18 at 13:16
add a comment |
actually i am not looking any css. I want to do the authentication in my pop up window. Here nothing to do with the css i guess
– Kazi
Nov 13 '18 at 13:16
actually i am not looking any css. I want to do the authentication in my pop up window. Here nothing to do with the css i guess
– Kazi
Nov 13 '18 at 13:16
actually i am not looking any css. I want to do the authentication in my pop up window. Here nothing to do with the css i guess
– Kazi
Nov 13 '18 at 13:16
add a comment |
The issue is that window.close
is closing the window which the router then tries to navigate. You need the logIn method to handle the routing logic for the original instance of the app once the login window is closed. Example:
logIn()
const newwindow = window.open(authUrl, "pop Up", "width=250, height= 250 ");
newwindow.onbeforeunload = () =>
if (localStorage.getItem('access_token'))
this.router.navigate(['manager']);
this.apiRequest();
else
// login failed
hi unfortunently its not working. Before windows is closing or user logged in, ` newwindow.onbeforeunload = () => if (localStorage.getItem('access_token')) this.router.navigate(['manager']); this.apiRequest(); else // login failed ` this line of code is executing. @teddy-sterne
– Kazi
Nov 13 '18 at 13:49
add a comment |
The issue is that window.close
is closing the window which the router then tries to navigate. You need the logIn method to handle the routing logic for the original instance of the app once the login window is closed. Example:
logIn()
const newwindow = window.open(authUrl, "pop Up", "width=250, height= 250 ");
newwindow.onbeforeunload = () =>
if (localStorage.getItem('access_token'))
this.router.navigate(['manager']);
this.apiRequest();
else
// login failed
hi unfortunently its not working. Before windows is closing or user logged in, ` newwindow.onbeforeunload = () => if (localStorage.getItem('access_token')) this.router.navigate(['manager']); this.apiRequest(); else // login failed ` this line of code is executing. @teddy-sterne
– Kazi
Nov 13 '18 at 13:49
add a comment |
The issue is that window.close
is closing the window which the router then tries to navigate. You need the logIn method to handle the routing logic for the original instance of the app once the login window is closed. Example:
logIn()
const newwindow = window.open(authUrl, "pop Up", "width=250, height= 250 ");
newwindow.onbeforeunload = () =>
if (localStorage.getItem('access_token'))
this.router.navigate(['manager']);
this.apiRequest();
else
// login failed
The issue is that window.close
is closing the window which the router then tries to navigate. You need the logIn method to handle the routing logic for the original instance of the app once the login window is closed. Example:
logIn()
const newwindow = window.open(authUrl, "pop Up", "width=250, height= 250 ");
newwindow.onbeforeunload = () =>
if (localStorage.getItem('access_token'))
this.router.navigate(['manager']);
this.apiRequest();
else
// login failed
answered Nov 13 '18 at 13:19
Teddy SterneTeddy Sterne
7,27111729
7,27111729
hi unfortunently its not working. Before windows is closing or user logged in, ` newwindow.onbeforeunload = () => if (localStorage.getItem('access_token')) this.router.navigate(['manager']); this.apiRequest(); else // login failed ` this line of code is executing. @teddy-sterne
– Kazi
Nov 13 '18 at 13:49
add a comment |
hi unfortunently its not working. Before windows is closing or user logged in, ` newwindow.onbeforeunload = () => if (localStorage.getItem('access_token')) this.router.navigate(['manager']); this.apiRequest(); else // login failed ` this line of code is executing. @teddy-sterne
– Kazi
Nov 13 '18 at 13:49
hi unfortunently its not working. Before windows is closing or user logged in, ` newwindow.onbeforeunload = () => if (localStorage.getItem('access_token')) this.router.navigate(['manager']); this.apiRequest(); else // login failed ` this line of code is executing. @teddy-sterne
– Kazi
Nov 13 '18 at 13:49
hi unfortunently its not working. Before windows is closing or user logged in, ` newwindow.onbeforeunload = () => if (localStorage.getItem('access_token')) this.router.navigate(['manager']); this.apiRequest(); else // login failed ` this line of code is executing. @teddy-sterne
– Kazi
Nov 13 '18 at 13:49
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53281680%2fhow-can-i-show-the-data-in-angular-component-after-authentication-is-done-in-a-p%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown