-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from UW-Macrostrat/edit-ssr
Edit ssr
- Loading branch information
Showing
43 changed files
with
2,289 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM node:20 AS build | ||
|
||
ENV NODE_ENV=production | ||
|
||
WORKDIR /usr/src/app | ||
COPY . ./ | ||
|
||
RUN yarn cache clean | ||
RUN yarn add | ||
|
||
CMD ["sh", "server/server.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@macrostrat-web/security", | ||
"private": true, | ||
"main": "src/index.ts", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
// Handles fetch requests that require authentication | ||
export const secureFetch = async (url, options) => { | ||
|
||
options = { | ||
credentials: "include", | ||
...options, | ||
} | ||
|
||
const response = await fetch(url, options); | ||
|
||
if (response.status === 401 || response.status === 403) { | ||
|
||
const url = new URL(`${import.meta.env.VITE_MACROSTRAT_INGEST_API}/security/login`); | ||
url.searchParams.append("return_url", `${window.location.origin}/dev/security/endpoint`); | ||
|
||
window.open(url, '_blank').focus(); | ||
throw {name: "UnauthorizedError", message: "User is not logged in"} | ||
} | ||
|
||
return response | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {default as h} from "@macrostrat/hyper"; | ||
|
||
export function Page() { | ||
|
||
return h("div", [ | ||
h("span", "You are logged in, you can now close this tab.") | ||
]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { render, redirect } from 'vike/abort' | ||
|
||
export const guard = (pageContext) => { | ||
const { user } = pageContext | ||
|
||
console.log("User: ", user) | ||
|
||
if (user === undefined) { | ||
// Render the login page while preserving the URL. (This is novel technique | ||
// which we explain down below.) | ||
throw redirect(`${import.meta.env.VITE_MACROSTRAT_INGEST_API}/security/login?return_url=${pageContext.url}`) | ||
/* The more traditional way, redirect the user: | ||
throw redirect('/login') | ||
*/ | ||
} | ||
if (!user.groups.includes(1)) { | ||
// Render the error page and show message to the user | ||
return render(403, 'Only admins are allowed to access this page.') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {default as h} from "@macrostrat/hyper"; | ||
|
||
export function Page() { | ||
|
||
return h("div", [ | ||
h("h1", "Secure Page") | ||
]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
|
||
import {EditableCell2, EditableCell2Props} from "@blueprintjs/table"; | ||
|
||
import hyper from "@macrostrat/hyper"; | ||
import styles from "./main.module.sass"; | ||
import { getTableUpdate } from "~/pages/maps/@id/edit/table-util"; | ||
|
||
export const h = hyper.styled(styles); | ||
|
||
|
||
interface EditableCell extends EditableCell2Props { | ||
columnName: string, | ||
rowIndex: number | ||
} | ||
|
||
export const EditableCell = ({...props}: EditableCell2Props) => { | ||
|
||
return h(EditableCell2, {...props}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {Button, MenuItem} from "@blueprintjs/core"; | ||
import {Select2, ItemRenderer} from "@blueprintjs/select"; | ||
import {EditableCell2Props} from "@blueprintjs/table"; | ||
import React, {useEffect, useMemo} from "react"; | ||
|
||
// @ts-ignore | ||
import hyper from "@macrostrat/hyper"; | ||
|
||
import "@blueprintjs/core/lib/css/blueprint.css" | ||
import "@blueprintjs/select/lib/css/blueprint-select.css"; | ||
import styles from "../../edit-table.module.sass"; | ||
|
||
|
||
const h = hyper.styled(styles); | ||
|
||
|
||
export const EditorPopover = () => { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
interface CellProps extends React.HTMLProps<HTMLTableCellElement> { | ||
value: string; | ||
onChange: (value: string) => void; | ||
} |
Oops, something went wrong.