Also display erroneous PGP keys
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
16d7fe4beb
commit
57d37544f9
3
keys.go
3
keys.go
@ -126,8 +126,7 @@ func declareAPIAuthKeysRoutes(router *gin.RouterGroup) {
|
|||||||
k := c.MustGet("key").(*Key)
|
k := c.MustGet("key").(*Key)
|
||||||
|
|
||||||
if err := k.ReadInfos(u); err != nil {
|
if err := k.ReadInfos(u); err != nil {
|
||||||
log.Println("Unable to ReadInfos:", err)
|
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": fmt.Sprintf("Unable to read your public key: %s", err.Error())})
|
||||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to read your public key. Please try again in a few moment."})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,3 +59,15 @@ export async function getKey(kid, userid) {
|
|||||||
throw new Error((await res.json()).errmsg);
|
throw new Error((await res.json()).errmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function deleteKey(kid, userid) {
|
||||||
|
const res = await fetch(userid?`api/users/${userid}/keys/${kid}`:`api/keys/${kid}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {'Accept': 'application/json'}
|
||||||
|
})
|
||||||
|
if (res.status == 200) {
|
||||||
|
return await res.json();
|
||||||
|
} else {
|
||||||
|
throw new Error((await res.json()).errmsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import { getKeys, getKey, Key } from '../lib/key';
|
import { deleteKey, getKeys, getKey, Key } from '../lib/key';
|
||||||
import { user } from '../stores/user';
|
import { user } from '../stores/user';
|
||||||
import { ToastsStore } from '../stores/toasts';
|
import { ToastsStore } from '../stores/toasts';
|
||||||
|
|
||||||
@ -72,6 +72,22 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{:catch err}
|
||||||
|
<div class="alert alert-danger d-flex justify-content-between">
|
||||||
|
<p>
|
||||||
|
<strong>Il y a une erreur avec cette clef :</strong>
|
||||||
|
{err}
|
||||||
|
</p>
|
||||||
|
<div class="d-flex flex-column justify-content-center">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn btn-outline-danger float-end"
|
||||||
|
on:click={() => deleteKey(keyid).then(() => { keysP = getKeys(); })}
|
||||||
|
>
|
||||||
|
Supprimer la clef
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{/await}
|
{/await}
|
||||||
{/each}
|
{/each}
|
||||||
{:else}
|
{:else}
|
||||||
|
Reference in New Issue
Block a user