Fixes for review comments.
This commit is contained in:
parent
4a31045233
commit
4086c8f439
|
@ -9,7 +9,7 @@
|
|||
async function generateAPIKey() {
|
||||
try {
|
||||
apiKey = await auth.generateAPIKey()
|
||||
notifications.success("New API key generated.")
|
||||
notifications.success("New API key generated")
|
||||
} catch (err) {
|
||||
notifications.error("Unable to generate new API key")
|
||||
}
|
||||
|
@ -18,7 +18,11 @@
|
|||
}
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
apiKey = await auth.fetchAPIKey()
|
||||
} catch (err) {
|
||||
notifications.error("Unable to fetch API key")
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@
|
|||
</MenuItem>
|
||||
{#if $auth.isBuilder}
|
||||
<MenuItem icon="Key" on:click={() => apiKeyModal.show()}>
|
||||
View developer information
|
||||
View API key
|
||||
</MenuItem>
|
||||
{/if}
|
||||
<MenuItem
|
||||
|
|
|
@ -173,12 +173,11 @@ export function createAuthStore() {
|
|||
})
|
||||
},
|
||||
generateAPIKey: async () => {
|
||||
const info = await API.generateAPIKey()
|
||||
return info?.apiKey ? info.apiKey : null
|
||||
return API.generateAPIKey()
|
||||
},
|
||||
fetchAPIKey: async () => {
|
||||
const info = await API.fetchDeveloperInfo()
|
||||
return info?.apiKey ? info.apiKey : null
|
||||
return info?.apiKey
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -5,9 +5,10 @@ export const buildSelfEndpoints = API => ({
|
|||
* @return {Promise<object>} returns the API response, including an API key.
|
||||
*/
|
||||
generateAPIKey: async () => {
|
||||
return await API.post({
|
||||
const response = await API.post({
|
||||
url: "/api/global/self/api_key",
|
||||
})
|
||||
return response?.apiKey
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -15,8 +16,39 @@ export const buildSelfEndpoints = API => ({
|
|||
* @return {Promise<object>} An object containing the user developer information.
|
||||
*/
|
||||
fetchDeveloperInfo: async () => {
|
||||
return await API.get({
|
||||
return API.get({
|
||||
url: "/api/global/self/api_key",
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetches the currently logged-in user object.
|
||||
* Used in client apps.
|
||||
*/
|
||||
fetchSelf: async () => {
|
||||
return await API.get({
|
||||
url: "/api/self",
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetches the currently logged-in user object.
|
||||
* Used in the builder.
|
||||
*/
|
||||
fetchBuilderSelf: async () => {
|
||||
return await API.get({
|
||||
url: "/api/global/self",
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the current logged-in user.
|
||||
* @param user the new user object to save
|
||||
*/
|
||||
updateSelf: async user => {
|
||||
return await API.post({
|
||||
url: "/api/global/self",
|
||||
body: user,
|
||||
})
|
||||
},
|
||||
})
|
||||
|
|
|
@ -1,24 +1,4 @@
|
|||
export const buildUserEndpoints = API => ({
|
||||
/**
|
||||
* Fetches the currently logged-in user object.
|
||||
* Used in client apps.
|
||||
*/
|
||||
fetchSelf: async () => {
|
||||
return await API.get({
|
||||
url: "/api/self",
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetches the currently logged-in user object.
|
||||
* Used in the builder.
|
||||
*/
|
||||
fetchBuilderSelf: async () => {
|
||||
return await API.get({
|
||||
url: "/api/global/self",
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets a list of users in the current tenant.
|
||||
*/
|
||||
|
@ -61,17 +41,6 @@ export const buildUserEndpoints = API => ({
|
|||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the current logged-in user.
|
||||
* @param user the new user object to save
|
||||
*/
|
||||
updateSelf: async user => {
|
||||
return await API.post({
|
||||
url: "/api/global/self",
|
||||
body: user,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates or updates a user in the current tenant.
|
||||
* @param user the new user to create
|
||||
|
|
Loading…
Reference in New Issue