[ADD] generate UUID if it's not set (#338)

* support openID2.0

* generate UUID if it's not set
This commit is contained in:
yubo 2020-10-14 15:02:58 +08:00 committed by GitHub
parent ecc736be8b
commit 91700ab93e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

1
.gitignore vendored
View File

@ -34,6 +34,7 @@ _test
/etc/log/log.test.json
/data*
/tarball
/run
.idea
.index

View File

@ -205,6 +205,10 @@ func (u *User) Save() error {
return fmt.Errorf("user.id[%d] not equal 0", u.Id)
}
if u.UUID == "" {
u.UUID = GenUUIDForUser(u.Username)
}
cnt, err := DB["rdb"].Where("username=?", u.Username).Count(new(User))
if err != nil {
return err