Skip to content

Commit

Permalink
fix: add force auth login process to get token
Browse files Browse the repository at this point in the history
  • Loading branch information
bompo committed Oct 30, 2024
1 parent f924671 commit 203ff4b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/LoginWithAuth0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,18 @@ export const isLoginRequired = (instanceUrl: string): boolean => {

/**
* Initializes Auth0 login process using redirect if necessary and retrieves an access token.
* Stops the process if login is not required or if NOVA_USERNAME and NOVA_PASSWORD are set.
*/
export const loginWithAuth0 = async (
instanceUrl: string,
forceAuthLogin: boolean = false,
): Promise<string | null> => {
// Check if login is required
if (!isLoginRequired(instanceUrl)) {
console.log("Login not required for this instance.")
return null
}

// Check if NOVA_USERNAME and NOVA_PASSWORD environment variables are set
if (process.env.NOVA_USERNAME && process.env.NOVA_PASSWORD) {
console.log("NOVA_USERNAME and NOVA_PASSWORD are set. Skipping login.")
return null
if (!forceAuthLogin) {
if (!isLoginRequired(instanceUrl)) {
// Check if login is required
console.log("Login not required for this instance.")
return null
}
}

// Get the appropriate Auth0 configuration based on the instance URL
Expand Down

0 comments on commit 203ff4b

Please sign in to comment.