Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(playground): repair trigger display #1722

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,10 @@ services:
restart: always
ports:
- 1234:1234
networks:
- fbs
environment:
- FBS_ROOT_URL=https://core
- FBS_ROOT_URL=https://core:443
- NODE_TLS_REJECT_UNAUTHORIZED=0

networks:
Expand Down
25 changes: 15 additions & 10 deletions modules/fbs-collab/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@ const FBS_ROOT_URL = process.env.FBS_ROOT_URL ?? 'https://feedback.mni.thm.de';
const server = new Hocuspocus({
port: 1234,
async onAuthenticate(data: onAuthenticatePayload): Promise<any> {
let userId;
try {
userId = jose.decodeJwt(data.token).id;
let userId;
try {
userId = jose.decodeJwt(data.token).id;
} catch (e) {
throw new Error("Unauthorized");
}
if (!userId) throw new Error("Unauthorized");
const resp = await fetch(`${FBS_ROOT_URL}/api/v1/users/${userId}/groups`, {headers: {'Authorization': `Bearer ${data.token}`}});
if (resp.status !== 200) throw new Error("Unauthorized");
const body = await resp.json();
const ok = Boolean(body.find(({id}: { id: string }) => id.toString() === data.documentName));
if (!ok) throw new Error("Forbidden");
return {user: {id: userId}};
} catch (e) {
throw new Error("Unauthorized");
console.log(e)
throw e
}
if (!userId) throw new Error("Unauthorized");
const resp = await fetch(`${FBS_ROOT_URL}/api/v1/users/${userId}/groups`, {headers: {'Authorization': `Bearer ${data.token}`}});
if (resp.status !== 200) throw new Error("Unauthorized");
const body = await resp.json();
const ok = Boolean(body.find(({id}: {id: string}) => id.toString() === data.documentName));
if (!ok) throw new Error("Forbidden");
return {user: {id: userId}};
},
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export interface Trigger {
export interface Trigger extends TriggerEvent, TriggerAction {
name: string;
event: TriggerEvent;
action: TriggerAction;
}

interface TriggerEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
</mat-expansion-panel-header>
<div class="trigger">
<span>
{{ trigger.action.timing }} {{ trigger.event.manipulation }}
{{ trigger.event.objecttable }}
{{ trigger.timing }} {{ trigger.manipulation }}
{{ trigger.objecttable }}
</span>
<span>FOR EACH {{ trigger.action.orientation }}</span>
<pre class="trigger-definition">{{ trigger.action.statement }}</pre>
<span>FOR EACH {{ trigger.orientation }}</span>
<pre class="trigger-definition">{{ trigger.statement }}</pre>
</div>
</mat-expansion-panel>
Loading