Fixes for review comments.
This commit is contained in:
parent
4a31045233
commit
4086c8f439
|
@ -9,7 +9,7 @@
|
||||||
async function generateAPIKey() {
|
async function generateAPIKey() {
|
||||||
try {
|
try {
|
||||||
apiKey = await auth.generateAPIKey()
|
apiKey = await auth.generateAPIKey()
|
||||||
notifications.success("New API key generated.")
|
notifications.success("New API key generated")
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notifications.error("Unable to generate new API key")
|
notifications.error("Unable to generate new API key")
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
try {
|
||||||
apiKey = await auth.fetchAPIKey()
|
apiKey = await auth.fetchAPIKey()
|
||||||
|
} catch (err) {
|
||||||
|
notifications.error("Unable to fetch API key")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{#if $auth.isBuilder}
|
{#if $auth.isBuilder}
|
||||||
<MenuItem icon="Key" on:click={() => apiKeyModal.show()}>
|
<MenuItem icon="Key" on:click={() => apiKeyModal.show()}>
|
||||||
View developer information
|
View API key
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{/if}
|
{/if}
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
|
|
@ -173,12 +173,11 @@ export function createAuthStore() {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
generateAPIKey: async () => {
|
generateAPIKey: async () => {
|
||||||
const info = await API.generateAPIKey()
|
return API.generateAPIKey()
|
||||||
return info?.apiKey ? info.apiKey : null
|
|
||||||
},
|
},
|
||||||
fetchAPIKey: async () => {
|
fetchAPIKey: async () => {
|
||||||
const info = await API.fetchDeveloperInfo()
|
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.
|
* @return {Promise<object>} returns the API response, including an API key.
|
||||||
*/
|
*/
|
||||||
generateAPIKey: async () => {
|
generateAPIKey: async () => {
|
||||||
return await API.post({
|
const response = await API.post({
|
||||||
url: "/api/global/self/api_key",
|
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.
|
* @return {Promise<object>} An object containing the user developer information.
|
||||||
*/
|
*/
|
||||||
fetchDeveloperInfo: async () => {
|
fetchDeveloperInfo: async () => {
|
||||||
return await API.get({
|
return API.get({
|
||||||
url: "/api/global/self/api_key",
|
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 => ({
|
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.
|
* 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.
|
* Creates or updates a user in the current tenant.
|
||||||
* @param user the new user to create
|
* @param user the new user to create
|
||||||
|
|
Loading…
Reference in New Issue