Compare commits
2 Commits
refactor/t
...
feat/fe-ac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4fdc05b5f | ||
|
|
4a0a5e6a04 |
@@ -13,7 +13,7 @@ SESSION_SECRET='add some secret here'
|
|||||||
# Hoppscotch App Domain Config
|
# Hoppscotch App Domain Config
|
||||||
REDIRECT_URL="http://localhost:3000"
|
REDIRECT_URL="http://localhost:3000"
|
||||||
WHITELISTED_ORIGINS = "http://localhost:3170,http://localhost:3000,http://localhost:3100"
|
WHITELISTED_ORIGINS = "http://localhost:3170,http://localhost:3000,http://localhost:3100"
|
||||||
ALLOWED_AUTH_PROVIDERS = GOOGLE,GITHUB,MICROSOFT,EMAIL
|
VITE_ALLOWED_AUTH_PROVIDERS = GOOGLE,GITHUB,MICROSOFT,EMAIL
|
||||||
|
|
||||||
# Google Auth Config
|
# Google Auth Config
|
||||||
GOOGLE_CLIENT_ID="************************************************"
|
GOOGLE_CLIENT_ID="************************************************"
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export const subscriptionContextCookieParser = (rawCookies: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if given auth provider is present in the ALLOWED_AUTH_PROVIDERS env variable
|
* Check to see if given auth provider is present in the VITE_ALLOWED_AUTH_PROVIDERS env variable
|
||||||
*
|
*
|
||||||
* @param provider Provider we want to check the presence of
|
* @param provider Provider we want to check the presence of
|
||||||
* @returns Boolean if provider specified is present or not
|
* @returns Boolean if provider specified is present or not
|
||||||
@@ -117,8 +117,8 @@ export function authProviderCheck(provider: string) {
|
|||||||
throwErr(AUTH_PROVIDER_NOT_SPECIFIED);
|
throwErr(AUTH_PROVIDER_NOT_SPECIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
const envVariables = process.env.ALLOWED_AUTH_PROVIDERS
|
const envVariables = process.env.VITE_ALLOWED_AUTH_PROVIDERS
|
||||||
? process.env.ALLOWED_AUTH_PROVIDERS.split(',').map((provider) =>
|
? process.env.VITE_ALLOWED_AUTH_PROVIDERS.split(',').map((provider) =>
|
||||||
provider.trim().toUpperCase(),
|
provider.trim().toUpperCase(),
|
||||||
)
|
)
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
@@ -29,22 +29,22 @@ export const JSON_INVALID = 'json_invalid';
|
|||||||
export const AUTH_PROVIDER_NOT_SPECIFIED = 'auth/provider_not_specified';
|
export const AUTH_PROVIDER_NOT_SPECIFIED = 'auth/provider_not_specified';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Environment variable "ALLOWED_AUTH_PROVIDERS" is not present in .env file
|
* Environment variable "VITE_ALLOWED_AUTH_PROVIDERS" is not present in .env file
|
||||||
*/
|
*/
|
||||||
export const ENV_NOT_FOUND_KEY_AUTH_PROVIDERS =
|
export const ENV_NOT_FOUND_KEY_AUTH_PROVIDERS =
|
||||||
'"ALLOWED_AUTH_PROVIDERS" is not present in .env file';
|
'"VITE_ALLOWED_AUTH_PROVIDERS" is not present in .env file';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Environment variable "ALLOWED_AUTH_PROVIDERS" is empty in .env file
|
* Environment variable "VITE_ALLOWED_AUTH_PROVIDERS" is empty in .env file
|
||||||
*/
|
*/
|
||||||
export const ENV_EMPTY_AUTH_PROVIDERS =
|
export const ENV_EMPTY_AUTH_PROVIDERS =
|
||||||
'"ALLOWED_AUTH_PROVIDERS" is empty in .env file';
|
'"VITE_ALLOWED_AUTH_PROVIDERS" is empty in .env file';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Environment variable "ALLOWED_AUTH_PROVIDERS" contains unsupported provider in .env file
|
* Environment variable "VITE_ALLOWED_AUTH_PROVIDERS" contains unsupported provider in .env file
|
||||||
*/
|
*/
|
||||||
export const ENV_NOT_SUPPORT_AUTH_PROVIDERS =
|
export const ENV_NOT_SUPPORT_AUTH_PROVIDERS =
|
||||||
'"ALLOWED_AUTH_PROVIDERS" contains an unsupported auth provider in .env file';
|
'"VITE_ALLOWED_AUTH_PROVIDERS" contains an unsupported auth provider in .env file';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tried to delete a user data document from fb firestore but failed.
|
* Tried to delete a user data document from fb firestore but failed.
|
||||||
|
|||||||
@@ -9,7 +9,12 @@ import * as E from 'fp-ts/Either';
|
|||||||
import * as A from 'fp-ts/Array';
|
import * as A from 'fp-ts/Array';
|
||||||
import { TeamMemberRole } from './team/team.model';
|
import { TeamMemberRole } from './team/team.model';
|
||||||
import { User } from './user/user.model';
|
import { User } from './user/user.model';
|
||||||
import { ENV_EMPTY_AUTH_PROVIDERS, ENV_NOT_FOUND_KEY_AUTH_PROVIDERS, ENV_NOT_SUPPORT_AUTH_PROVIDERS, JSON_INVALID } from './errors';
|
import {
|
||||||
|
ENV_EMPTY_AUTH_PROVIDERS,
|
||||||
|
ENV_NOT_FOUND_KEY_AUTH_PROVIDERS,
|
||||||
|
ENV_NOT_SUPPORT_AUTH_PROVIDERS,
|
||||||
|
JSON_INVALID,
|
||||||
|
} from './errors';
|
||||||
import { AuthProvider } from './auth/helper';
|
import { AuthProvider } from './auth/helper';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,21 +161,21 @@ export function isValidLength(title: string, length: number) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is called by bootstrap() in main.ts
|
* This function is called by bootstrap() in main.ts
|
||||||
* It checks if the "ALLOWED_AUTH_PROVIDERS" environment variable is properly set or not.
|
* It checks if the "VITE_ALLOWED_AUTH_PROVIDERS" environment variable is properly set or not.
|
||||||
* If not, it throws an error.
|
* If not, it throws an error.
|
||||||
*/
|
*/
|
||||||
export function checkEnvironmentAuthProvider() {
|
export function checkEnvironmentAuthProvider() {
|
||||||
if (!process.env.hasOwnProperty('ALLOWED_AUTH_PROVIDERS')) {
|
if (!process.env.hasOwnProperty('VITE_ALLOWED_AUTH_PROVIDERS')) {
|
||||||
throw new Error(ENV_NOT_FOUND_KEY_AUTH_PROVIDERS);
|
throw new Error(ENV_NOT_FOUND_KEY_AUTH_PROVIDERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.ALLOWED_AUTH_PROVIDERS === '') {
|
if (process.env.VITE_ALLOWED_AUTH_PROVIDERS === '') {
|
||||||
throw new Error(ENV_EMPTY_AUTH_PROVIDERS);
|
throw new Error(ENV_EMPTY_AUTH_PROVIDERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
const givenAuthProviders = process.env.ALLOWED_AUTH_PROVIDERS.split(',').map(
|
const givenAuthProviders = process.env.VITE_ALLOWED_AUTH_PROVIDERS.split(
|
||||||
(provider) => provider.toLocaleUpperCase(),
|
',',
|
||||||
);
|
).map((provider) => provider.toLocaleUpperCase());
|
||||||
const supportedAuthProviders = Object.values(AuthProvider).map(
|
const supportedAuthProviders = Object.values(AuthProvider).map(
|
||||||
(provider: string) => provider.toLocaleUpperCase(),
|
(provider: string) => provider.toLocaleUpperCase(),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user