Remove fmt.Println and add Zerolog logging system
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 1m2s
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 1m2s
This commit is contained in:
@@ -2,12 +2,12 @@ package handlers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/santhosh-tekuri/jsonschema/v5"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
@@ -19,12 +19,12 @@ func (h MobilityAccountsHandler) Login(username string, password string, namespa
|
||||
u := strings.ToLower(username)
|
||||
account, err := h.storage.DB.LocalAuthentication(namespace, &u, nil, nil)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
log.Error().Err(err).Msg("")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = bcrypt.CompareHashAndPassword([]byte(account.Authentication.Local.Password), []byte(password)); err != nil {
|
||||
fmt.Println(err)
|
||||
log.Error().Err(err).Msg("")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ func (h MobilityAccountsHandler) UpdateData(accountid string, datas map[string]a
|
||||
dataschemas := h.config.GetStringMap("data_schemas")
|
||||
for k, v := range datas {
|
||||
if !h.config.GetBool("allow_any_data") && dataschemas[k] == nil {
|
||||
fmt.Println("data scope not allowed")
|
||||
log.Error().Msg("data scope not allowed")
|
||||
return nil, errors.New("data scope not allowed")
|
||||
}
|
||||
|
||||
@@ -116,19 +116,19 @@ func (h MobilityAccountsHandler) UpdateData(accountid string, datas map[string]a
|
||||
s := dataschemas[k].(map[string]string)
|
||||
sch, err := jsonschema.Compile(s["schema"])
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
log.Error().Err(err).Msg("")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = sch.Validate(v); err != nil {
|
||||
fmt.Println(err)
|
||||
log.Error().Err(err).Msg("")
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
account.Data[k] = v
|
||||
}
|
||||
if err = h.storage.DB.UpdateAccount(*account); err != nil {
|
||||
fmt.Println(err)
|
||||
log.Error().Err(err).Msg("")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ func (h MobilityAccountsHandler) UpdatePhoneNumber(accountid, phone_number strin
|
||||
account.Authentication.Local.PhoneNumberValidation.ValidationCode = verification_code
|
||||
|
||||
if err = h.storage.DB.UpdateAccount(*account); err != nil {
|
||||
fmt.Println(err)
|
||||
log.Error().Err(err).Msg("")
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user