Skip to content

Commit 23d18c3

Browse files
Merge pull request #320 from aiondemand/fix/detail-view-bookmarks
fix: check user is authenticated before requesting bookmarks
2 parents 1e4db1a + 4097055 commit 23d18c3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/app/modules/marketplace/components/asset-detail/asset-detail.component.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ export class AssetDetailComponent implements OnInit, OnDestroy {
5959
this.breadcrumbService.set('@assetName', this.asset.name);
6060
this.isLoading = false;
6161
this.prepareGenericData();
62+
63+
if (!this.authService.isAuthActiveUser()) return;
64+
6265
// After asset is loaded, check if it's bookmarked
6366
const bookmarkSub = this.bookmarkService.getBookmarksList().subscribe({
6467
next: (bookmarks: AssetsPurchase[] | any) => {
@@ -107,7 +110,7 @@ export class AssetDetailComponent implements OnInit, OnDestroy {
107110
}
108111

109112
protected onClickBookmark(): void {
110-
if (!this.isAuthenticated()) return;
113+
if (!this.authService.isAuthActiveUser()) return;
111114

112115
if (!this.isBookmarked) {
113116
this.addBookmark();
@@ -148,11 +151,11 @@ export class AssetDetailComponent implements OnInit, OnDestroy {
148151
}
149152

150153
isAuthenticated(): boolean {
151-
return this.userProfile && Object.keys(this.userProfile).length > 0;
154+
return this.authService.isAuthActiveUser();
152155
}
153156

154157
private addBookmark() {
155-
if (this.userProfile) {
158+
if (this.authService.isAuthActiveUser()) {
156159
const bookmarkedAsset = this.getBookmarkedAsset();
157160

158161
this.bookmarkService.addBookmark(bookmarkedAsset.identifier).subscribe({
@@ -165,7 +168,7 @@ export class AssetDetailComponent implements OnInit, OnDestroy {
165168
}
166169

167170
private deleteBookmark() {
168-
if (this.userProfile) {
171+
if (this.authService.isAuthActiveUser()) {
169172
this.bookmarkService
170173
.deleteBookmark(this.asset.identifier.toString())
171174
.subscribe({

0 commit comments

Comments
 (0)