Commit ed3958ab authored by Anton's avatar Anton
Browse files

Do not use window in electron auth service

parent b21af278
Pipeline #17461 passed with stage
in 2 minutes and 34 seconds
...@@ -13,11 +13,11 @@ const ...@@ -13,11 +13,11 @@ const
keytarAccount = os.userInfo().username keytarAccount = os.userInfo().username
function getAuthenticationURL () { function getAuthenticationURL () {
return 'https://' + (window.AUTH0_DOMAIN || process.env.AUTH0_DOMAIN) + '/authorize?' + return 'https://' + (process.env.AUTH0_DOMAIN) + '/authorize?' +
'audience=' + (window.AUTH0_AUDIENCE || process.env.AUTH0_AUDIENCE) + '&' + 'audience=' + (process.env.AUTH0_AUDIENCE) + '&' +
'scope=openid profile offline_access&' + 'scope=openid profile offline_access&' +
'response_type=code&' + 'response_type=code&' +
'client_id=' + (window.AUTH0_CLIENT_ID || process.env.AUTH0_CLIENT_ID) + '&' + 'client_id=' + (process.env.AUTH0_CLIENT_ID) + '&' +
'redirect_uri=' + redirectUri 'redirect_uri=' + redirectUri
} }
...@@ -25,9 +25,9 @@ async function refreshTokens () { ...@@ -25,9 +25,9 @@ async function refreshTokens () {
const refreshToken = await keytar.getPassword(keytarService, keytarAccount) const refreshToken = await keytar.getPassword(keytarService, keytarAccount)
if (!refreshToken) return throw new Error('No refresh token found') if (!refreshToken) return throw new Error('No refresh token found')
const result = await axios.post(`https://${window.AUTH0_DOMAIN || process.env.AUTH0_DOMAIN}/oauth/token`, { const result = await axios.post(`https://${process.env.AUTH0_DOMAIN}/oauth/token`, {
grant_type: 'refresh_token', grant_type: 'refresh_token',
client_id: window.AUTH0_CLIENT_ID || process.env.AUTH0_CLIENT_ID, client_id: process.env.AUTH0_CLIENT_ID,
refresh_token: refreshToken refresh_token: refreshToken
}, { }, {
headers: {'Content-Type': 'application/json'} headers: {'Content-Type': 'application/json'}
...@@ -43,12 +43,12 @@ async function loadTokens (callbackURL) { ...@@ -43,12 +43,12 @@ async function loadTokens (callbackURL) {
const exchangeOptions = { const exchangeOptions = {
'grant_type': 'authorization_code', 'grant_type': 'authorization_code',
'client_id': window.AUTH0_CLIENT_ID || process.env.AUTH0_CLIENT_ID, 'client_id': process.env.AUTH0_CLIENT_ID,
'code': query.code, 'code': query.code,
'redirect_uri': redirectUri 'redirect_uri': redirectUri
} }
const result = await axios.post(`https://${window.AUTH0_DOMAIN || process.env.AUTH0_DOMAIN}/oauth/token`, exchangeOptions, { const result = await axios.post(`https://${process.env.AUTH0_DOMAIN}/oauth/token`, exchangeOptions, {
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
...@@ -66,7 +66,7 @@ async function logout () { ...@@ -66,7 +66,7 @@ async function logout () {
} }
function getLogOutUrl () { function getLogOutUrl () {
return `https://${window.AUTH0_DOMAIN || process.env.AUTH0_DOMAIN}/v2/logout` return `https://${process.env.AUTH0_DOMAIN}/v2/logout`
} }
export { export {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment