PSQL CreateAccount
This commit is contained in:
@@ -100,8 +100,41 @@ func (PostgresqlStorage) GetAccountsByIds(accountids []string) ([]Account, error
|
||||
return nil, fmt.Errorf("")
|
||||
}
|
||||
|
||||
func (PostgresqlStorage) CreateAccount(account Account) error {
|
||||
return fmt.Errorf("")
|
||||
func (psql PostgresqlStorage) CreateAccount(account Account) error {
|
||||
insertAccountStmt, err := psql.DbConnection.Prepare("INSERT INTO accounts (id, namespace, data, metadata) VALUES ($1, $2, $3, $4)")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dataAccountJson, err := json.Marshal(account.Data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
metadataAccountJson, err := json.Marshal(account.Metadata)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = insertAccountStmt.Exec(account.ID, account.Namespace, dataAccountJson, metadataAccountJson)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
insertAccountAuthStmt, err := psql.DbConnection.Prepare("INSERT INTO account_auth (account_id, username, password, email, email_validation,phone_number,phone_number_validation) values($1, $2, $3, $4, $5, $6, $7)")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
emailValidationJson, err := json.Marshal(account.Authentication.Local.EmailValidation)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
phoneValidationJson, err := json.Marshal(account.Authentication.Local.PhoneNumberValidation)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = insertAccountAuthStmt.Exec(account.ID, account.Authentication.Local.Username, account.Authentication.Local.Password,
|
||||
account.Authentication.Local.Email, emailValidationJson, account.Authentication.Local.PhoneNumber, phoneValidationJson)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (PostgresqlStorage) UpdateAccount(account Account) error {
|
||||
|
||||
Reference in New Issue
Block a user