Skip to content

Commit

Permalink
Only allowing dev login if REACT_APP_DEV_LOGIN === 'true'
Browse files Browse the repository at this point in the history
  • Loading branch information
ineiti committed Oct 4, 2023
1 parent 68cdb33 commit 76acfb0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions scripts/local_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ export SESSION_SECRET="session secret"
export REACT_APP_NOMOCK=on
# shellcheck disable=SC2155
export DB_PATH="$(pwd)/nodes/llmdb"
# The following two variables can be set to see log output from dela:
#export PROXY_LOG=info
#export LLVL=info
# If this is set, you can login without Gaspar
export REACT_APP_DEV_LOGIN="true"
4 changes: 2 additions & 2 deletions web/backend/src/controllers/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { getUserPermissions, readSCIPER, setMapAuthorization } from '../authMana
export const authenticationRouter = express.Router();

authenticationRouter.get('/get_dev_login', (req, res) => {
if (process.env.NODE_ENV !== 'development') {
const err = `/get_dev_login can only be called in development: ${process.env.NODE_ENV}`;
if (process.env.REACT_APP_DEV_LOGIN !== 'true') {
const err = `/get_dev_login can only be called with DEV_LOGIN===true: ${process.env.DEV_LOGIN}`;
console.error(err);
res.status(500).send(err);
return;
Expand Down
3 changes: 2 additions & 1 deletion web/frontend/src/pages/session/HandleLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { FlashLevel, FlashState } from 'index';

// The backend will provide the client the URL to make a Tequila authentication.
// We therefore redirect to this address.
// If REACT_APP_DEV_LOGIN === "true", we allow an automatic login with SCIPER 100100.
const handleLogin = async (fctx: FlashState) => {
try {
let res;
if (process.env.NODE_ENV === 'development') {
if (process.env.REACT_APP_DEV_LOGIN === 'true') {
await fetch(ENDPOINT_DEV_LOGIN);
window.location.reload();
return;
Expand Down

0 comments on commit 76acfb0

Please sign in to comment.