Skip to content

Commit cac2358

Browse files
committed
removed SET_AUTH=none option
1 parent bad67de commit cac2358

10 files changed

Lines changed: 17 additions & 40 deletions

File tree

webmoti-react/.env.example

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ TWILIO_API_KEY_SID=SKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
44
TWILIO_API_KEY_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
55
TWILIO_CONVERSATIONS_SERVICE_SID=ISxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
66

7-
# Auth mode: (choose one)
8-
# none: local testing without auth
7+
# Auth mode:
8+
# leave unset: local testing without auth
99
# passcode: passcode that expires after a week (not secure)
1010
# firebase: secure with firebase auth (use this for deploying)
11-
# VITE_SET_AUTH=none
12-
# VITE_SET_AUTH=passcode
1311
VITE_SET_AUTH=firebase
1412

1513
# required for firebase auth

webmoti-react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@
8989
"server": "ts-node -T -P server/tsconfig.json server/index.ts",
9090
"typescript:server": "tsc --noEmit -p server/",
9191
"cypress:open": "cypress open",
92-
"cypress:dev": "cross-env VITE_SET_AUTH=none CYPRESS_baseUrl=http://localhost:3000 start-server-and-test start http://localhost:8081 cypress:open",
92+
"cypress:dev": "cross-env VITE_SET_AUTH= CYPRESS_baseUrl=http://localhost:3000 start-server-and-test start http://localhost:8081 cypress:open",
9393
"cypress:run": "cypress run --browser chrome",
94-
"cypress:ci": "cross-env VITE_SET_AUTH=none npm run build && cross-env VITE_SET_AUTH=none CYPRESS_baseUrl=http://localhost:8081 start-server-and-test server http://localhost:8081 cypress:run",
94+
"cypress:ci": "cross-env VITE_SET_AUTH= npm run build && cross-env VITE_SET_AUTH= CYPRESS_baseUrl=http://localhost:8081 start-server-and-test server http://localhost:8081 cypress:run",
9595
"deploy:base": "cross-env VITE_SET_AUTH=firebase npm run build && twilio rtc:apps:video:deploy --authentication=firebase --app-directory ./build --override",
9696
"deploy:base:passcode": "cross-env VITE_SET_AUTH=passcode npm run build && twilio rtc:apps:video:deploy --authentication=passcode --app-directory ./build --override",
9797
"deploy": "npm run deploy:base -- --room-type=group",

webmoti-react/src/clientEnv.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
const validAuthModes = ['firebase', 'passcode', 'none'] as const;
2-
type AuthMode = (typeof validAuthModes)[number];
3-
4-
const requiredEnvVars = {
5-
VITE_SET_AUTH: validAuthModes,
6-
} satisfies Record<string, readonly string[]>;
7-
81
// it uses functions for easier mocking in jest tests
92
const clientEnv = {
103
FIREBASE_API_KEY: () => import.meta.env.VITE_FIREBASE_API_KEY,
@@ -16,7 +9,7 @@ const clientEnv = {
169

1710
LIVEKIT_URL: () => import.meta.env.VITE_LIVEKIT_URL,
1811

19-
SET_AUTH: () => import.meta.env.VITE_SET_AUTH as AuthMode,
12+
SET_AUTH: () => import.meta.env.VITE_SET_AUTH,
2013
DISABLE_TWILIO_CONVERSATIONS: () => import.meta.env.VITE_DISABLE_TWILIO_CONVERSATIONS,
2114
TOKEN_ENDPOINT: () => import.meta.env.VITE_TOKEN_ENDPOINT,
2215
ROOM_TYPE: () => import.meta.env.VITE_ROOM_TYPE,
@@ -27,18 +20,4 @@ const clientEnv = {
2720
IS_DEV_MODE: () => import.meta.env.DEV,
2821
};
2922

30-
function validateEnvVars(rules: Record<string, readonly string[]>) {
31-
for (const [key, allowed] of Object.entries(rules)) {
32-
const val = import.meta.env[key];
33-
if (!val) {
34-
throw new Error(`Missing required environment variable: ${key}`);
35-
}
36-
if (!allowed.includes(val)) {
37-
throw new Error(`Invalid value for ${key}: "${val}". Expected one of: ${allowed.join(', ')}`);
38-
}
39-
}
40-
}
41-
42-
validateEnvVars(requiredEnvVars);
43-
4423
export { clientEnv };

webmoti-react/src/components/LoginPage/LoginPage.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('the LoginPage component', () => {
109109
});
110110

111111
it('should redirect to "/" when auth is disabled', () => {
112-
(clientEnv.SET_AUTH as jest.Mock).mockReturnValue("none");
112+
(clientEnv.SET_AUTH as jest.Mock).mockReturnValue(undefined);
113113
mockUseAppState.mockImplementation(() => ({ user: null, signIn: () => Promise.resolve(), isAuthReady: true }));
114114
render(<LoginPage />);
115115
expect(mockNavigate).toHaveBeenCalledWith('/', { replace: true });

webmoti-react/src/components/LoginPage/LoginPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default function LoginPage() {
7272
const [passcode, setPasscode] = useState('');
7373
const [authError, setAuthError] = useState<Error | null>(null);
7474

75-
const isAuthEnabled = clientEnv.SET_AUTH() !== 'none';
75+
const isAuthEnabled = !!clientEnv.SET_AUTH();
7676

7777
const from = (location.state as { from?: Location })?.from?.pathname || '/';
7878

webmoti-react/src/components/MenuBar/MenuBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default function MenuBar() {
6565
<Typography variant="body1">
6666
{/* only show room name in dev */}
6767
{/* also show when SET_AUTH is none (in cypress tests) */}
68-
{(clientEnv.IS_DEV_MODE() || clientEnv.SET_AUTH() === 'none') && `${room!.name}`}
68+
{(clientEnv.IS_DEV_MODE() || !clientEnv.SET_AUTH()) && `${room!.name}`}
6969
{/* {' | '}
7070
{participants.length + 1} participant
7171
{participants.length ? 's' : ''} */}

webmoti-react/src/components/PreJoinScreens/RoomNameScreen/RoomNameScreen.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,9 @@ export default function RoomNameScreen({ name, roomName, setName, setRoomName, h
9999
/>
100100
</div>
101101
)}
102-
{/* hide room name field when running prod */}
103-
{/* (it confuses participants and we only need one room for now) */}
104-
{/* also show when SET_AUTH is none (in cypress tests) */}
105-
{(clientEnv.IS_DEV_MODE() || clientEnv.SET_AUTH() === 'none') && (
102+
{/* show room name field in dev or when auth is disabled (in cypress tests) */}
103+
{/* hide in prod when auth is enabled */}
104+
{(clientEnv.IS_DEV_MODE() || !clientEnv.SET_AUTH()) && (
106105
<div className={classes.textFieldContainer}>
107106
<InputLabel shrink htmlFor="input-room-name">
108107
Room Name

webmoti-react/src/components/PrivateRoute/PrivateRoute.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('PrivateRoute', () => {
8383

8484
describe('with auth disabled', () => {
8585
it('renders children regardless of user or authReady', () => {
86-
(clientEnv.SET_AUTH as jest.Mock).mockReturnValue("none");
86+
(clientEnv.SET_AUTH as jest.Mock).mockReturnValue(undefined);
8787
mockUseAppState.mockReturnValue({ user: null, isAuthReady: false });
8888

8989
render(

webmoti-react/src/components/PrivateRoute/PrivateRoute.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export default function PrivateRoute({ children }: Props) {
1212
const { isAuthReady, user } = useAppState();
1313
const location = useLocation();
1414

15-
const renderChildren = user || clientEnv.SET_AUTH() === 'none';
15+
const isAuthDisabled = !clientEnv.SET_AUTH();
16+
const renderChildren = user || isAuthDisabled;
1617

1718
if (!renderChildren && !isAuthReady) {
1819
return null;

webmoti-react/src/state/index.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ const wrapper = ({ children }: { children: ReactNode }) => <AppStateProvider>{ch
2828
describe('the useAppState hook', () => {
2929
beforeEach(jest.clearAllMocks);
3030
beforeEach(() => {
31-
(clientEnv.SET_AUTH as jest.Mock).mockReturnValue("none");
32-
(clientEnv.TOKEN_ENDPOINT as jest.Mock).mockReturnValue("none");
31+
(clientEnv.SET_AUTH as jest.Mock).mockReturnValue(undefined);
32+
(clientEnv.TOKEN_ENDPOINT as jest.Mock).mockReturnValue(undefined);
3333
});
3434

3535
it('should set an error', () => {
@@ -63,7 +63,7 @@ describe('the useAppState hook', () => {
6363

6464
describe('with auth disabled', () => {
6565
it('should not use any auth hooks', async () => {
66-
(clientEnv.SET_AUTH as jest.Mock).mockReturnValue("none");
66+
(clientEnv.SET_AUTH as jest.Mock).mockReturnValue(undefined);
6767

6868
renderHook(useAppState, { wrapper });
6969
expect(useFirebaseAuth).not.toHaveBeenCalled();

0 commit comments

Comments
 (0)