Skip to content

Commit

Permalink
remove and re-add platform on server restart
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsTheGlidingSquirrel committed Jun 11, 2024
1 parent 64744ad commit ac4d798
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion saltire-platform.config

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,11 @@ ltijs.app.post("/lti/finish-deeplink", async (req, res) => {
const setup = async () => {
await ltijs.deploy();

/**
* Register platform
*/
// Remove platform (if it exists)
// There might be already an entry in mongodb for this platform. On restart, we want to remove it and re-add it to prevent the issue `bad decrypt`. See: https://github.com/Cvmcosta/ltijs/issues/119#issuecomment-882898770
ltijs.deletePlatform(ltiPlatform.url, ltiPlatform.clientId);

// Register platform
await ltijs.registerPlatform({
url: ltiPlatform.url,
name: ltiPlatform.name,
Expand All @@ -228,6 +230,7 @@ const setup = async () => {
key: ltiPlatform.keysetEndpoint,
},
});
// Register Moodle as platform
// await ltijs.registerPlatform({
// url: "http://localhost",
// name: "Moodle",
Expand Down
5 changes: 1 addition & 4 deletions src/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { SerloEditor } from "@serlo/editor";
import { useEffect, useState } from "react";
import * as jwt from "jsonwebtoken";

function App() {
// TODO: Make editorState always contain valid value
Expand Down Expand Up @@ -42,8 +41,6 @@ function App() {
const ltik = urlParams.get("ltik");
if (!accessToken || !ltik) return <p>Access token or ltik was missing!</p>;

const decodedAccessToken = jwt.decode(accessToken);

const isDeeplink = urlParams.get("deeplink");

return (
Expand Down Expand Up @@ -83,7 +80,7 @@ function App() {
</SerloEditor>
<h2>Debug info</h2>
<h3>Access token:</h3>
<div>{JSON.stringify(decodedAccessToken)}</div>
<div>{accessToken}</div>
<h3>ltik:</h3>
<div>{ltik}</div>
</>
Expand Down

0 comments on commit ac4d798

Please sign in to comment.