diff --git a/app/config/config.go b/app/config/config.go index b92dfbc..2ffbe11 100644 --- a/app/config/config.go +++ b/app/config/config.go @@ -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" @@ -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") diff --git a/app/controllers/auth/sign_up.go b/app/controllers/auth/sign_up.go index e21794e..3de36a0 100644 --- a/app/controllers/auth/sign_up.go +++ b/app/controllers/auth/sign_up.go @@ -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) diff --git a/app/entities/user.go b/app/entities/user.go index df94875..a2f01ef 100644 --- a/app/entities/user.go +++ b/app/entities/user.go @@ -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 diff --git a/go.mod b/go.mod index f2d2542..4ed0c5a 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index 4c8079b..4151ff6 100644 --- a/go.sum +++ b/go.sum @@ -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=