testing PSQL GetAccount

This commit is contained in:
2023-04-25 20:07:26 +02:00
parent 95262a685c
commit d1e71e32f9
4 changed files with 264 additions and 32 deletions

View File

@@ -41,7 +41,7 @@ func NewPostgresqlStorage(cfg *viper.Viper) (PostgresqlStorage, error) {
func (psql PostgresqlStorage) GetAccount(id string) (*Account, error) {
var (
data, metadata, emailValidation []byte
data, metadata, emailValidation, phoneValidation []byte
)
account := &Account{}
if isUUIDv4(id) {
@@ -62,7 +62,7 @@ func (psql PostgresqlStorage) GetAccount(id string) (*Account, error) {
if err != nil {
return account, err
}
stmtAccount_auth, err := psql.DbConnection.Prepare("SELECT local_username,local_password, local_email, local_email_validation, local_phone_number, local_phone_number_validation FROM account_auth WHERE account_id= $1")
stmtAccount_auth, err := psql.DbConnection.Prepare("SELECT username, password, email, email_validation, phone_number, phone_number_validation FROM account_auth WHERE account_id= $1")
if err != nil {
return account, fmt.Errorf("psql connection failed")
}
@@ -72,7 +72,7 @@ func (psql PostgresqlStorage) GetAccount(id string) (*Account, error) {
&account.Authentication.Local.Email,
&emailValidation,
&account.Authentication.Local.PhoneNumber,
&account.Authentication.Local.PhoneNumberValidation)
&phoneValidation)
if err != nil {
return account, fmt.Errorf("psql select account auth query failed")
}
@@ -80,6 +80,10 @@ func (psql PostgresqlStorage) GetAccount(id string) (*Account, error) {
if err != nil {
return account, err
}
err = json.Unmarshal(phoneValidation, &account.Authentication.Local.PhoneNumberValidation)
if err != nil {
return account, err
}
}
return account, nil
}