Skip to content

Commit 6781a15

Browse files
committed
Added localstorage value for the nsid in the browser. Needs more data eventually
1 parent 62a3412 commit 6781a15

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

server/src/routes/admin-router.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ export default function adminRouter(dbController: DatabaseController): Router {
8383
res.status(403).json({ error: "Access denied" });
8484
}
8585
const token = jwt.sign(
86-
{ username: casData.user, roles: casData.roles },
86+
{ username: nsid},
8787
process.env.JWT_SECRET!,
8888
{ expiresIn: "3h" },
8989
);
90-
res.json({token});
90+
res.json({token: token, nsid: nsid});
9191
} else {
9292
res.status(401).json({ error: 'CAS authentication failed' });
9393

web/src/auth/CASCallback.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ const CASCallback: React.FC = () => {
1616
return response.json()})
1717
.then((data) => {
1818
if (data.token) {
19-
// Store JWT in localStorage or cookies
19+
// Store JWT in localStorage
2020
localStorage.setItem('jwt', data.token);
21+
// Store nsid in localStorage
22+
localStorage.setItem('nsid', data.nsid);
2123
// Redirect to a protected page or home
2224
window.location.href = '/';
2325
} else {

0 commit comments

Comments
 (0)