Fetch PGP keys from GitLab CRI as fallback
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2022-09-14 00:19:43 +02:00
commit c2f2910a83
2 changed files with 90 additions and 7 deletions

15
keys.go
View file

@ -33,9 +33,18 @@ func declareAPIKeysRoutes(router *gin.RouterGroup) {
}
var ret []byte
for _, key := range keys {
if key.Type == "pgp" {
ret = append(ret, []byte(key.Content)...)
if len(keys) == 0 {
ret, err = GitLab_getUserPGPKeys(c.Request.Context(), u)
if err != nil {
log.Println("Unable to GitLab_getUserPGPKeys:", err)
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to retrieve your keys from GitLab. Please try again in a few moment or add them directly on /keys page on this website."})
return
}
} else {
for _, key := range keys {
if key.Type == "pgp" {
ret = append(ret, []byte(key.Content)...)
}
}
}