|
|
|
@ -4,13 +4,12 @@ import { getEnvVars } from '../../Environment'; |
|
|
|
const { oAuthConfig } = getEnvVars(); |
|
|
|
|
|
|
|
getLoginData = (username, password) => { |
|
|
|
|
|
|
|
const formData = { |
|
|
|
grant_type: 'password', |
|
|
|
scope: oAuthConfig.scope, |
|
|
|
username: username, |
|
|
|
password: password, |
|
|
|
client_id: oAuthConfig.clientId |
|
|
|
client_id: oAuthConfig.clientId, |
|
|
|
}; |
|
|
|
|
|
|
|
if (oAuthConfig.clientSecret) |
|
|
|
@ -19,7 +18,7 @@ getLoginData = (username, password) => { |
|
|
|
return Object.entries(formData) |
|
|
|
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`) |
|
|
|
.join('&'); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
export const login = ({ username, password }) => |
|
|
|
api({ |
|
|
|
@ -27,15 +26,28 @@ export const login = ({ username, password }) => |
|
|
|
url: '/connect/token', |
|
|
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, |
|
|
|
data: getLoginData(username, password), |
|
|
|
baseURL: oAuthConfig.issuer |
|
|
|
baseURL: oAuthConfig.issuer, |
|
|
|
}).then(({ data }) => data); |
|
|
|
|
|
|
|
export const Logout = ( |
|
|
|
input = { client_id: '', token: '', token_type_hint: '' }, |
|
|
|
) => { |
|
|
|
if (!input.token_type_hint) { |
|
|
|
input.token_type_hint = 'access_token'; |
|
|
|
} |
|
|
|
|
|
|
|
export const Logout = () => |
|
|
|
api({ |
|
|
|
method: 'GET', |
|
|
|
url: '/api/account/logout', |
|
|
|
const _data = Object.entries(input) |
|
|
|
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`) |
|
|
|
.join('&'); |
|
|
|
|
|
|
|
return api({ |
|
|
|
method: 'POST', |
|
|
|
url: '/connect/revocat', |
|
|
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, |
|
|
|
data: _data, |
|
|
|
baseURL: oAuthConfig.issuer, |
|
|
|
}).then(({ data }) => data); |
|
|
|
}; |
|
|
|
|
|
|
|
export const getTenant = tenantName => |
|
|
|
api({ |
|
|
|
|