Created
May 26, 2020 01:58
-
-
Save sir-dunxalot/e4596ce78c7d77031dad34ec2e2218b8 to your computer and use it in GitHub Desktop.
cypress-nextjs-auth0__helper--login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import auth0 from 'auth0-js'; | |
const auth = new auth0.WebAuth({ | |
domain: Cypress.env('auth0Domain'), | |
clientID: Cypress.env('auth0ClientId'), | |
}); | |
Cypress.Commands.add('login', (credentials) => { | |
const { username, password } = credentials; | |
return new Cypress.Promise((resolve, reject) => { | |
auth.client.loginWithDefaultDirectory({ | |
username, | |
password, | |
audience: Cypress.env('auth0Audience'), | |
scope: Cypress.env('auth0Scope'), | |
client_secret: Cypress.env('auth0ClientSecret'), | |
}, (err, response) => { | |
if (err) { | |
reject(err); | |
} else { | |
resolve(response); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment