Просмотр исходного кода

generate authkey in user creation api

Mike 2 лет назад
Родитель
Сommit
433efc7451
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      server/mgmt_api.go

+ 3 - 0
server/mgmt_api.go

@@ -4,6 +4,8 @@ import (
 	"encoding/json"
 	"fmt"
 	"net/http"
+
+	"github.com/google/uuid"
 )
 
 func StartManagementAPI(fs *FeedbagStore) {
@@ -51,6 +53,7 @@ func createUser(fs *FeedbagStore, w http.ResponseWriter, r *http.Request) {
 		http.Error(w, err.Error(), http.StatusBadRequest)
 		return
 	}
+	newUser.AuthKey = uuid.New().String()
 	// todo does the request contain authkey?
 	newUser.HashPassword(newUser.Password)
 	if err := fs.InsertUser(newUser.User); err != nil {