Skip to content

Commit

Permalink
add suporte campos nulos do banco de dados
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniloCarSan committed Sep 11, 2022
1 parent 1df5965 commit 9523cb6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
3 changes: 3 additions & 0 deletions app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var (
APP_PORT = ""
APP_HOST = ""
APP_HOST_FULL = ""
APP_URL = ""
SENTRY_DNS = ""
DB_DRIVE = "mysql"
DB_ADDR = "%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local"
Expand Down Expand Up @@ -53,6 +54,8 @@ func Load(fileEnv string) error {

APP_HOST_FULL = fmt.Sprintf("%s:%s", APP_HOST, APP_PORT)

APP_URL = fmt.Sprintf("http://%s", APP_HOST_FULL)

value, exists = os.LookupEnv("SENTRY_DNS")
if value == "" || !exists {
return errors.New("not found variable APP_PORT in .env file or variable empty")
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/auth/sign_up.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func SignUp(c *gin.Context) {
}

go func() {
link := fmt.Sprintf("http://%s%s%s", config.APP_HOST_FULL, "/auth/email/verify/", credential.Token)
link := fmt.Sprintf("%s%s%s", config.APP_URL, "/auth/email/verify/", credential.Token)

emailSignUpbody = strings.ReplaceAll(emailSignUpbody, "{{LINK}}", link)

Expand Down
18 changes: 10 additions & 8 deletions app/entities/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import (
"gotaskapp/app/security"
"strings"
"time"

"gopkg.in/guregu/null.v4/zero"
)

type User struct {
ID uint64 `json:"id,omitempty"`
Avatar string `json:"avatar,omitempty"`
Firstname string `json:"firstname,omitempty"`
Lastname string `json:"lastname,omitempty"`
Email string `json:"email,omitempty"`
Password string `json:"-"`
Verified string `json:"verified"`
CreateAt time.Time `json:"-"`
ID uint64 `json:"id,omitempty"`
Avatar zero.String `json:"avatar,omitempty"`
Firstname string `json:"firstname,omitempty"`
Lastname string `json:"lastname,omitempty"`
Email string `json:"email,omitempty"`
Password string `json:"-"`
Verified string `json:"verified"`
CreateAt time.Time `json:"-"`
}

// Convert password to hash
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ require (
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/guregu/null.v4 v4.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/guregu/null.v4 v4.0.0 h1:1Wm3S1WEA2I26Kq+6vcW+w0gcDo44YKYD7YIEJNHDjg=
gopkg.in/guregu/null.v4 v4.0.0/go.mod h1:YoQhUrADuG3i9WqesrCmpNRwm1ypAgSHYqoOcTu/JrI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down

0 comments on commit 9523cb6

Please sign in to comment.