⚡ Fix link account always update cache record
This commit is contained in:
parent
97e1d1f87e
commit
2116e5b390
@ -1,23 +1,23 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
pwpb "git.solsynth.dev/hydrogen/identity/pkg/grpc/proto"
|
||||
idpb "git.solsynth.dev/hydrogen/identity/pkg/grpc/proto"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
var Notify pwpb.NotifyClient
|
||||
var Auth pwpb.AuthClient
|
||||
var Notify idpb.NotifyClient
|
||||
var Auth idpb.AuthClient
|
||||
|
||||
func ConnectPassport() error {
|
||||
addr := viper.GetString("identity.grpc_endpoint")
|
||||
if conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials())); err != nil {
|
||||
return err
|
||||
} else {
|
||||
Notify = pwpb.NewNotifyClient(conn)
|
||||
Auth = pwpb.NewAuthClient(conn)
|
||||
Notify = idpb.NewNotifyClient(conn)
|
||||
Auth = idpb.NewAuthClient(conn)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"git.solsynth.dev/hydrogen/identity/pkg/grpc/proto"
|
||||
@ -37,6 +38,7 @@ func LinkAccount(userinfo *proto.Userinfo) (models.Account, error) {
|
||||
return account, err
|
||||
}
|
||||
|
||||
prev := account
|
||||
account.Name = userinfo.Name
|
||||
account.Nick = userinfo.Nick
|
||||
account.Avatar = userinfo.Avatar
|
||||
@ -44,7 +46,10 @@ func LinkAccount(userinfo *proto.Userinfo) (models.Account, error) {
|
||||
account.Description = userinfo.GetDescription()
|
||||
account.EmailAddress = userinfo.Email
|
||||
|
||||
err := database.C.Save(&account).Error
|
||||
var err error
|
||||
if !reflect.DeepEqual(prev, account) {
|
||||
err = database.C.Save(&account).Error
|
||||
}
|
||||
|
||||
return account, err
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ secret = "LtTjzAGFLshwXhN4ZD4nG5KlMv1MWcsvfv03TSZYnT1VhiAnLIZFTnHUwR0XhGgi"
|
||||
content = "uploads"
|
||||
|
||||
[debug]
|
||||
database = true
|
||||
database = false
|
||||
print_routes = false
|
||||
|
||||
[identity]
|
||||
|
Loading…
Reference in New Issue
Block a user