Skip to content

Commit

Permalink
Merge branch 'master' into add-public-dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
GspikeHalo authored Jan 11, 2025
2 parents 7873603 + d4de38f commit 20c57aa
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import edu.uci.ics.texera.web.resource.dashboard.user.dataset.{
DatasetAccessResource,
DatasetResource
}
import edu.uci.ics.texera.web.resource.dashboard.user.discussion.UserDiscussionResource
import edu.uci.ics.texera.web.resource.dashboard.user.project.{
ProjectAccessResource,
ProjectResource,
Expand Down Expand Up @@ -147,7 +146,6 @@ class TexeraWebApplication
environment.jersey.register(classOf[GmailResource])
environment.jersey.register(classOf[AdminExecutionResource])
environment.jersey.register(classOf[UserQuotaResource])
environment.jersey.register(classOf[UserDiscussionResource])
environment.jersey.register(classOf[AIAssistantResource])
}
}

This file was deleted.

1 change: 1 addition & 0 deletions core/gui/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ registerLocaleData(en);
tokenGetter: AuthService.getAccessToken,
skipWhenExpired: false,
throwNoTokenError: false,
disallowedRoutes: ["forum/api/users"],
},
}),
BrowserAnimationsModule,
Expand Down
44 changes: 24 additions & 20 deletions core/gui/src/app/dashboard/component/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,6 @@ export class DashboardComponent implements OnInit {

this.isCollpased = false;

if (!document.cookie.includes("flarum_remember") && this.isLogin) {
this.flarumService
.auth()
.pipe(untilDestroyed(this))
.subscribe({
next: (response: any) => {
document.cookie = `flarum_remember=${response.token};path=/`;
},
error: (err: unknown) => {
if ([404, 500].includes((err as HttpErrorResponse).status)) {
this.displayForum = false;
} else {
this.flarumService
.register()
.pipe(untilDestroyed(this))
.subscribe(() => this.ngOnInit());
}
},
});
}
this.router.events.pipe(untilDestroyed(this)).subscribe(() => {
this.checkRoute();
});
Expand All @@ -94,11 +74,35 @@ export class DashboardComponent implements OnInit {
this.ngZone.run(() => {
this.isLogin = this.userService.isLogin();
this.isAdmin = this.userService.isAdmin();
this.forumLogin();
this.cdr.detectChanges();
});
});
}

forumLogin() {
if (!document.cookie.includes("flarum_remember") && this.isLogin) {
this.flarumService
.auth()
.pipe(untilDestroyed(this))
.subscribe({
next: (response: any) => {
document.cookie = `flarum_remember=${response.token};path=/`;
},
error: (err: unknown) => {
if ([404, 500].includes((err as HttpErrorResponse).status)) {
this.displayForum = false;
} else {
this.flarumService
.register()
.pipe(untilDestroyed(this))
.subscribe(() => this.forumLogin());
}
},
});
}
}

checkRoute() {
const currentRoute = this.router.url;
this.displayNavbar = this.isNavbarEnabled(currentRoute);
Expand Down
23 changes: 14 additions & 9 deletions core/gui/src/app/dashboard/service/user/flarum/flarum.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { UserService } from "../../../../common/service/user/user.service";
import { AppSettings } from "../../../../common/app-setting";

@Injectable({
providedIn: "root",
Expand All @@ -11,16 +10,22 @@ export class FlarumService {
private http: HttpClient,
private userService: UserService
) {}
public register() {
return this.http.put(`${AppSettings.getApiEndpoint()}/discussion/register`, {});
}

auth() {
const currentUser = this.userService.getCurrentUser();
register() {
const user = this.userService.getCurrentUser();
return this.http.post(
"forum/api/token",
{ identification: currentUser!.email, password: currentUser!.googleId, remember: "1" },
{ headers: { "Content-Type": "application/json" }, withCredentials: true }
"forum/api/users",
{
data: {
attributes: { username: user!.email.split("@")[0] + user!.uid, email: user!.email, password: user!.googleId },
},
},
{ headers: { Authorization: "Token hdebsyxiigyklxgsqivyswwiisohzlnezzzzzzzz;userId=1" } }
);
}

auth() {
const user = this.userService.getCurrentUser();
return this.http.post("forum/api/token", { identification: user!.email, password: user!.googleId, remember: "1" });
}
}

0 comments on commit 20c57aa

Please sign in to comment.