Extend PostgreSQL implementation and unit tests on MongoDB storage

This commit is contained in:
2023-05-02 00:34:33 +02:00
parent 1bf02aa132
commit c6ba00b74f
18 changed files with 870 additions and 752 deletions

View File

@@ -10,9 +10,10 @@ import (
)
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,
@@ -42,12 +43,12 @@ func (lc LocalAuth) ToStorageType() storage.LocalAuth {
Username: lc.Username,
Password: lc.Password,
Email: lc.Email,
EmailValidation: storage.Validation{
EmailValidation: &storage.Validation{
Validated: lc.EmailValidation.Validated,
ValidationCode: lc.EmailValidation.ValidationCode,
},
PhoneNumber: lc.PhoneNumber,
PhoneNumberValidation: storage.Validation{
PhoneNumberValidation: &storage.Validation{
Validated: lc.PhoneNumberValidation.Validated,
ValidationCode: lc.PhoneNumberValidation.ValidationCode,
},
@@ -55,7 +56,10 @@ func (lc LocalAuth) ToStorageType() storage.LocalAuth {
}
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 {