resolve conflicts
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 1m5s
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 1m5s
This commit is contained in:
34
grpcapi/accounts.go
Normal file → Executable file
34
grpcapi/accounts.go
Normal file → Executable file
@@ -2,17 +2,18 @@ package grpcapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||
"github.com/rs/zerolog/log"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/types/known/structpb"
|
||||
)
|
||||
|
||||
func (a Account) ToStorageType() storage.Account {
|
||||
var localauth storage.LocalAuth
|
||||
var localauth *storage.LocalAuth
|
||||
if a.Authentication != nil && a.Authentication.Local != nil {
|
||||
localauth = a.Authentication.Local.ToStorageType()
|
||||
la := a.Authentication.Local.ToStorageType()
|
||||
localauth = &la
|
||||
}
|
||||
account := storage.Account{
|
||||
ID: a.Id,
|
||||
@@ -26,7 +27,7 @@ func (a Account) ToStorageType() storage.Account {
|
||||
for k, d := range a.Data.GetFields() {
|
||||
jsondata, err := protojson.Marshal(d)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
log.Error().Err(err).Msg("")
|
||||
break
|
||||
}
|
||||
var data any
|
||||
@@ -51,17 +52,26 @@ func (lc LocalAuth) ToStorageType() storage.LocalAuth {
|
||||
}
|
||||
|
||||
return storage.LocalAuth{
|
||||
Username: lc.Username,
|
||||
Password: lc.Password,
|
||||
Email: lc.Email,
|
||||
EmailValidation: emailValidation,
|
||||
PhoneNumber: lc.PhoneNumber,
|
||||
PhoneNumberValidation: phoneValidation,
|
||||
Username: lc.Username,
|
||||
Password: lc.Password,
|
||||
Email: lc.Email,
|
||||
EmailValidation: &storage.Validation{
|
||||
Validated: lc.EmailValidation.Validated,
|
||||
ValidationCode: lc.EmailValidation.ValidationCode,
|
||||
},
|
||||
PhoneNumber: lc.PhoneNumber,
|
||||
PhoneNumberValidation: &storage.Validation{
|
||||
Validated: lc.PhoneNumberValidation.Validated,
|
||||
ValidationCode: lc.PhoneNumberValidation.ValidationCode,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func AccountFromStorageType(account *storage.Account) (*Account, error) {
|
||||
lc := LocalAuthFromStorageType(account.Authentication.Local)
|
||||
var lc *LocalAuth
|
||||
if account.Authentication.Local != nil {
|
||||
lc = LocalAuthFromStorageType(*account.Authentication.Local)
|
||||
}
|
||||
|
||||
d, err := sanitizeData(account.Data)
|
||||
if err != nil {
|
||||
@@ -70,7 +80,7 @@ func AccountFromStorageType(account *storage.Account) (*Account, error) {
|
||||
|
||||
data, err := structpb.NewStruct(d)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
log.Error().Err(err).Msg("")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user