convert public key from newline delimited string to a real array

Added a compatibility layer that will convert newline delimited keys to array
when the user is fetched from the database.
This code will be removed in future versions please update your public keys,
you only need to resave the users using the REST API.
This commit is contained in:
Nicola Murino
2019-08-01 22:42:46 +02:00
parent 788e068e13
commit 8d4964c16d
10 changed files with 71 additions and 43 deletions

View File

@@ -65,7 +65,7 @@ func getUserByID(w http.ResponseWriter, r *http.Request) {
user, err := dataprovider.GetUserByID(dataProvider, userID)
if err == nil {
user.Password = ""
user.PublicKey = ""
user.PublicKey = []string{}
render.JSON(w, r, user)
} else if err == sql.ErrNoRows {
sendAPIResponse(w, r, err, "", http.StatusNotFound)
@@ -86,7 +86,7 @@ func addUser(w http.ResponseWriter, r *http.Request) {
user, err = dataprovider.UserExists(dataProvider, user.Username)
if err == nil {
user.Password = ""
user.PublicKey = ""
user.PublicKey = []string{}
render.JSON(w, r, user)
} else {
sendAPIResponse(w, r, err, "", http.StatusInternalServerError)