Angular - AuthGuard is redirecting Iframe
up vote
1
down vote
favorite
I am implementing an iFrame in my angular application. When i am giving the src url directly in the html, the app is working fine and loading the requested UI. But when i am fetching the src url from backend and passing it as a variable auth guard is redirecting the url to login page. How to fix this?
DefectsManagementComponent.html:
<div class="container-fluid dtep-style dtep-min-height-569px-minus-56px">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="form-group"></div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<iframe id="defects" class="col-lg-12 col-md-12 col-sm-12 col-xs-12" title="Defects Management" src="url">
</iframe>
</div>
</div>
</div>
</div>
DefectsManagementComponent.ts:
export class DefectsManagementComponent implements OnInit {
url: string;
constructor(private service: SolutionInstanceService) {
}
ngOnInit() {
this.service.fetchSolutionByName("DEFECT_MANAGEMENT").subscribe(data =>{
this.url = data["solutionURL"];
});
}
}
AppRoutingModule.ts:
const routes: Routes = [
{
path: "login",
component: LoginComponent
},
{
path: "home",
canActivate: [AuthGuardGuard],
component: HomeComponent
},
{
path: "defects",
component: DefectsManagementComponent
},
{
path: "",
redirectTo: "login",
pathMatch: "full"
},
{
path: "**",
redirectTo: "login",
pathMatch: "full"
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule
angular iframe auth-guard
|
show 7 more comments
up vote
1
down vote
favorite
I am implementing an iFrame in my angular application. When i am giving the src url directly in the html, the app is working fine and loading the requested UI. But when i am fetching the src url from backend and passing it as a variable auth guard is redirecting the url to login page. How to fix this?
DefectsManagementComponent.html:
<div class="container-fluid dtep-style dtep-min-height-569px-minus-56px">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="form-group"></div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<iframe id="defects" class="col-lg-12 col-md-12 col-sm-12 col-xs-12" title="Defects Management" src="url">
</iframe>
</div>
</div>
</div>
</div>
DefectsManagementComponent.ts:
export class DefectsManagementComponent implements OnInit {
url: string;
constructor(private service: SolutionInstanceService) {
}
ngOnInit() {
this.service.fetchSolutionByName("DEFECT_MANAGEMENT").subscribe(data =>{
this.url = data["solutionURL"];
});
}
}
AppRoutingModule.ts:
const routes: Routes = [
{
path: "login",
component: LoginComponent
},
{
path: "home",
canActivate: [AuthGuardGuard],
component: HomeComponent
},
{
path: "defects",
component: DefectsManagementComponent
},
{
path: "",
redirectTo: "login",
pathMatch: "full"
},
{
path: "**",
redirectTo: "login",
pathMatch: "full"
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule
angular iframe auth-guard
can you try with src in square brackets? ( [src]="url" )
– Andrei Dumitrescu-Tudor
Nov 19 at 7:12
i tried but still same result.
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:26
try console logging url after it has been set, to see if it is the correct value. If that is the return of an http call, you might need to call result on it.
– Andrei Dumitrescu-Tudor
Nov 19 at 7:30
I have logged it, the value is being fetched but when i am inspecting, it is showing the value of src as null in the source code.
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:31
Most of the times it is trying to access "http:localhost:4200/url" When i am giving src="url", it is accessing "http:localhost:4200/url" and when i change it to [src]="url", the url value is null
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:39
|
show 7 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am implementing an iFrame in my angular application. When i am giving the src url directly in the html, the app is working fine and loading the requested UI. But when i am fetching the src url from backend and passing it as a variable auth guard is redirecting the url to login page. How to fix this?
DefectsManagementComponent.html:
<div class="container-fluid dtep-style dtep-min-height-569px-minus-56px">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="form-group"></div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<iframe id="defects" class="col-lg-12 col-md-12 col-sm-12 col-xs-12" title="Defects Management" src="url">
</iframe>
</div>
</div>
</div>
</div>
DefectsManagementComponent.ts:
export class DefectsManagementComponent implements OnInit {
url: string;
constructor(private service: SolutionInstanceService) {
}
ngOnInit() {
this.service.fetchSolutionByName("DEFECT_MANAGEMENT").subscribe(data =>{
this.url = data["solutionURL"];
});
}
}
AppRoutingModule.ts:
const routes: Routes = [
{
path: "login",
component: LoginComponent
},
{
path: "home",
canActivate: [AuthGuardGuard],
component: HomeComponent
},
{
path: "defects",
component: DefectsManagementComponent
},
{
path: "",
redirectTo: "login",
pathMatch: "full"
},
{
path: "**",
redirectTo: "login",
pathMatch: "full"
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule
angular iframe auth-guard
I am implementing an iFrame in my angular application. When i am giving the src url directly in the html, the app is working fine and loading the requested UI. But when i am fetching the src url from backend and passing it as a variable auth guard is redirecting the url to login page. How to fix this?
DefectsManagementComponent.html:
<div class="container-fluid dtep-style dtep-min-height-569px-minus-56px">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="form-group"></div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<iframe id="defects" class="col-lg-12 col-md-12 col-sm-12 col-xs-12" title="Defects Management" src="url">
</iframe>
</div>
</div>
</div>
</div>
DefectsManagementComponent.ts:
export class DefectsManagementComponent implements OnInit {
url: string;
constructor(private service: SolutionInstanceService) {
}
ngOnInit() {
this.service.fetchSolutionByName("DEFECT_MANAGEMENT").subscribe(data =>{
this.url = data["solutionURL"];
});
}
}
AppRoutingModule.ts:
const routes: Routes = [
{
path: "login",
component: LoginComponent
},
{
path: "home",
canActivate: [AuthGuardGuard],
component: HomeComponent
},
{
path: "defects",
component: DefectsManagementComponent
},
{
path: "",
redirectTo: "login",
pathMatch: "full"
},
{
path: "**",
redirectTo: "login",
pathMatch: "full"
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule
angular iframe auth-guard
angular iframe auth-guard
edited Nov 19 at 7:23
Iman
5011
5011
asked Nov 19 at 7:07
Yerramsetty G D SuryaPrakash
145
145
can you try with src in square brackets? ( [src]="url" )
– Andrei Dumitrescu-Tudor
Nov 19 at 7:12
i tried but still same result.
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:26
try console logging url after it has been set, to see if it is the correct value. If that is the return of an http call, you might need to call result on it.
– Andrei Dumitrescu-Tudor
Nov 19 at 7:30
I have logged it, the value is being fetched but when i am inspecting, it is showing the value of src as null in the source code.
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:31
Most of the times it is trying to access "http:localhost:4200/url" When i am giving src="url", it is accessing "http:localhost:4200/url" and when i change it to [src]="url", the url value is null
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:39
|
show 7 more comments
can you try with src in square brackets? ( [src]="url" )
– Andrei Dumitrescu-Tudor
Nov 19 at 7:12
i tried but still same result.
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:26
try console logging url after it has been set, to see if it is the correct value. If that is the return of an http call, you might need to call result on it.
– Andrei Dumitrescu-Tudor
Nov 19 at 7:30
I have logged it, the value is being fetched but when i am inspecting, it is showing the value of src as null in the source code.
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:31
Most of the times it is trying to access "http:localhost:4200/url" When i am giving src="url", it is accessing "http:localhost:4200/url" and when i change it to [src]="url", the url value is null
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:39
can you try with src in square brackets? ( [src]="url" )
– Andrei Dumitrescu-Tudor
Nov 19 at 7:12
can you try with src in square brackets? ( [src]="url" )
– Andrei Dumitrescu-Tudor
Nov 19 at 7:12
i tried but still same result.
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:26
i tried but still same result.
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:26
try console logging url after it has been set, to see if it is the correct value. If that is the return of an http call, you might need to call result on it.
– Andrei Dumitrescu-Tudor
Nov 19 at 7:30
try console logging url after it has been set, to see if it is the correct value. If that is the return of an http call, you might need to call result on it.
– Andrei Dumitrescu-Tudor
Nov 19 at 7:30
I have logged it, the value is being fetched but when i am inspecting, it is showing the value of src as null in the source code.
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:31
I have logged it, the value is being fetched but when i am inspecting, it is showing the value of src as null in the source code.
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:31
Most of the times it is trying to access "http:localhost:4200/url" When i am giving src="url", it is accessing "http:localhost:4200/url" and when i change it to [src]="url", the url value is null
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:39
Most of the times it is trying to access "http:localhost:4200/url" When i am giving src="url", it is accessing "http:localhost:4200/url" and when i change it to [src]="url", the url value is null
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:39
|
show 7 more comments
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
You should use square brackets around src to bind the value of url to it, otherwise you are assigning the string “url” to src. Also use ngIf on the iframe to only show it when url is populated. You then need to sanitize the url. See more at https://stackoverflow.com/a/38269951/10632970 .
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You should use square brackets around src to bind the value of url to it, otherwise you are assigning the string “url” to src. Also use ngIf on the iframe to only show it when url is populated. You then need to sanitize the url. See more at https://stackoverflow.com/a/38269951/10632970 .
add a comment |
up vote
2
down vote
accepted
You should use square brackets around src to bind the value of url to it, otherwise you are assigning the string “url” to src. Also use ngIf on the iframe to only show it when url is populated. You then need to sanitize the url. See more at https://stackoverflow.com/a/38269951/10632970 .
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You should use square brackets around src to bind the value of url to it, otherwise you are assigning the string “url” to src. Also use ngIf on the iframe to only show it when url is populated. You then need to sanitize the url. See more at https://stackoverflow.com/a/38269951/10632970 .
You should use square brackets around src to bind the value of url to it, otherwise you are assigning the string “url” to src. Also use ngIf on the iframe to only show it when url is populated. You then need to sanitize the url. See more at https://stackoverflow.com/a/38269951/10632970 .
answered Nov 19 at 8:29
Andrei Dumitrescu-Tudor
1798
1798
add a comment |
add a comment |
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%2f53369811%2fangular-authguard-is-redirecting-iframe%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
can you try with src in square brackets? ( [src]="url" )
– Andrei Dumitrescu-Tudor
Nov 19 at 7:12
i tried but still same result.
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:26
try console logging url after it has been set, to see if it is the correct value. If that is the return of an http call, you might need to call result on it.
– Andrei Dumitrescu-Tudor
Nov 19 at 7:30
I have logged it, the value is being fetched but when i am inspecting, it is showing the value of src as null in the source code.
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:31
Most of the times it is trying to access "http:localhost:4200/url" When i am giving src="url", it is accessing "http:localhost:4200/url" and when i change it to [src]="url", the url value is null
– Yerramsetty G D SuryaPrakash
Nov 19 at 7:39