This commit is contained in:
parent
632f476092
commit
16d7fe4beb
6
keys.go
6
keys.go
@ -95,6 +95,12 @@ func declareAPIAuthKeysRoutes(router *gin.RouterGroup) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
k2 := key
|
||||||
|
if err := k2.ReadInfos(u); err != nil {
|
||||||
|
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
k, err := u.NewKey(key.Type, key.Content)
|
k, err := u.NewKey(key.Type, key.Content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Unable to NewKey:", err)
|
log.Println("Unable to NewKey:", err)
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
{:then keys}
|
{:then keys}
|
||||||
{#if keys && keys.length > 0}
|
{#if keys && keys.length > 0}
|
||||||
{#each keys as keyid}
|
{#each keys as keyid}
|
||||||
{#await getKey(keyid)}
|
{#await getKey(keyid, student.id)}
|
||||||
Veuillez patienter
|
Veuillez patienter
|
||||||
{:then key}
|
{:then key}
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -51,8 +51,8 @@ export async function getKeys(userid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getKey(kid) {
|
export async function getKey(kid, userid) {
|
||||||
const res = await fetch(`api/keys/${kid}`, {headers: {'Accept': 'application/json'}})
|
const res = await fetch(userid?`api/users/${userid}/keys/${kid}`:`api/keys/${kid}`, {headers: {'Accept': 'application/json'}})
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
return new Key(await res.json());
|
return new Key(await res.json());
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user