Skip to content

Commit a5e9bab

Browse files
authored
add localhost flag for skipping auth check in teacher tool (#10589)
1 parent 5ecc2f7 commit a5e9bab

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

teachertool/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Requests to the `/eval` endpoint will be routed to the Teacher Tool dev server.
1313

1414
Debug and step through Teacher Tool code using the browser dev tools (F12 to open).
1515

16+
To skip having to log in on localhost, add `?noauth=1` to the end of the url.
17+
1618

1719
## Test in staging environment
1820

teachertool/src/App.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,23 @@ export const App = () => {
6464

6565
useEffect(() => {
6666
async function checkAuthAsync() {
67-
// On mount, check if user is signed in
68-
try {
69-
await authClient.authCheckAsync();
70-
} catch (e) {
71-
// Log error but continue
72-
// Don't include actual error in error log in case PII
73-
logError(ErrorCode.authCheckFailed);
74-
logDebug("Auth check failed details", e);
67+
if (pxt.BrowserUtils.isLocalHostDev() && /noauth=1/i.test(window.location.href)) {
68+
dispatch(Actions.setUserProfile({
69+
id: "?"
70+
}));
7571
}
72+
else {
73+
// On mount, check if user is signed in
74+
try {
75+
await authClient.authCheckAsync();
76+
} catch (e) {
77+
// Log error but continue
78+
// Don't include actual error in error log in case PII
79+
logError(ErrorCode.authCheckFailed);
80+
logDebug("Auth check failed details", e);
81+
}
82+
}
83+
7684
setAuthCheckComplete(true);
7785
}
7886
checkAuthAsync();

0 commit comments

Comments
 (0)