Skip to content

Commit

Permalink
[fix] #48 , #129
Browse files Browse the repository at this point in the history
  • Loading branch information
yoneyan committed Oct 29, 2021
1 parent d3898a4 commit 5721711
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
14 changes: 5 additions & 9 deletions pkg/api/core/tool/gen/gen.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package gen

import (
"fmt"
"github.com/google/uuid"
uuidLib "github.com/google/uuid"
)

func GenerateUUID() string {
u, err := uuid.NewRandom()
func GenerateUUIDString() (string, error) {
uuid, err := uuidLib.NewRandom()
if err != nil {
fmt.Println(err)
//return ""
return "", err
}
uu := u.String()

return uu
return uuid.String(), nil
}
11 changes: 11 additions & 0 deletions pkg/api/core/tool/gen/gen_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package gen

import "testing"

func TestGenerateUUIDString(t *testing.T) {
uuid, err := GenerateUUIDString()
if err != nil {
t.Fatalf("error: %s\n", err)
}
t.Logf("UUID: %s\n", uuid)
}
6 changes: 5 additions & 1 deletion pkg/api/core/user/v0/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ func AddGroup(c *gin.Context) {
return
}

pass = gen.GenerateUUID()
pass, err = gen.GenerateUUIDString()
if err != nil {
c.JSON(http.StatusInternalServerError, common.Error{Error: "error: Failed to generate uuid. "})
return
}

data = core.User{
GroupID: resultAuth.User.GroupID,
Expand Down

0 comments on commit 5721711

Please sign in to comment.