6 files changed,
25 insertions(+),
4 deletions(-)
Author:
Smirnov Oleksandr
ss2316544@gmail.com
Committed by:
GitHub
noreply@github.com
Committed at:
2024-09-15 09:06:12 +0300
Parent:
1c67ba5
M
e2e/e2e_test.go
··· 106 106 e.mailer, 107 107 cfg.JwtRefreshTokenTTL, 108 108 cfg.VerficationTokenTTL, 109 + cfg.AppURL, 109 110 ) 110 111 111 112 noterepo := noterepo.New(e.postgresDB) ··· 177 178 func (e *AppTestSuite) getConfig() *config.Config { 178 179 return &config.Config{ //nolint:exhaustruct 179 180 AppEnv: "testing", 181 + AppURL: "", 180 182 ServerPort: "3000", 181 183 PasswordSalt: "salty-password", 182 184 JwtSigningKey: "jwt-key",
M
internal/config/config.go
··· 8 8 9 9 type Config struct { 10 10 AppEnv string 11 + AppURL string 11 12 ServerPort string 12 13 PostgresDSN string 13 14 PasswordSalt string ··· 29 30 func NewConfig() *Config { 30 31 return &Config{ 31 32 AppEnv: getenvOrDefault("APP_ENV", "debug"), 33 + AppURL: getenvOrDefault("APP_URL", ""), 32 34 ServerPort: getenvOrDefault("SERVER_PORT", "3000"), 33 35 PostgresDSN: getenvOrDefault("POSTGRESQL_DSN", ""), 34 36 PasswordSalt: getenvOrDefault("PASSWORD_SALT", ""),
M
internal/service/usersrv/email.go
··· 23 23 cancel context.CancelFunc, 24 24 userEmail string, 25 25 token string, 26 + url string, 26 27 ) error { 27 28 select { 28 29 case <-ctx.Done(): ··· 33 34 ctx, 34 35 userEmail, 35 36 verificationEmailSubject, 36 - // TODO: set proper url 37 - fmt.Sprintf(verificationEmailBody, "http://localhost:3000", token), 37 + fmt.Sprintf(verificationEmailBody, url, token), 38 38 ); err != nil { 39 39 return errors.Join(ErrFailedToSendVerifcationEmail, err) 40 40 }
M
internal/service/usersrv/usersrv.go
··· 45 45 46 46 refreshTokenTTL time.Duration 47 47 verificationTokenTTL time.Duration 48 + appURL string 48 49 } 49 50 50 51 func New( ··· 55 56 jwtTokenizer jwtutil.JWTTokenizer, 56 57 mailer mailer.Mailer, 57 58 refreshTokenTTL, verificationTokenTTL time.Duration, 59 + appURL string, 58 60 ) *UserSrv { 59 61 return &UserSrv{ 60 62 userstore: userstore, ··· 65 67 mailer: mailer, 66 68 refreshTokenTTL: refreshTokenTTL, 67 69 verificationTokenTTL: verificationTokenTTL, 70 + appURL: appURL, 68 71 } 69 72 } 70 73 ··· 93 96 // TODO: handle the error that might be returned 94 97 // i dont think that tehre's need to handle the error, just log it 95 98 bgCtx, bgCancel := context.WithTimeout(context.Background(), 10*time.Second) 96 - go u.sendVerificationEmail(bgCtx, bgCancel, inp.Email, vtok) //nolint:errcheck,contextcheck 99 + go u.sendVerificationEmail( //nolint:errcheck,contextcheck 100 + bgCtx, 101 + bgCancel, 102 + inp.Email, 103 + vtok, 104 + u.appURL, 105 + ) 97 106 98 107 return uid, nil 99 108 } ··· 211 220 } 212 221 213 222 bgCtx, bgCancel := context.WithTimeout(context.Background(), 10*time.Second) 214 - go u.sendVerificationEmail(bgCtx, bgCancel, inp.Email, token) //nolint:errcheck,contextcheck 223 + go u.sendVerificationEmail( //nolint:errcheck,contextcheck 224 + bgCtx, 225 + bgCancel, 226 + inp.Email, 227 + token, 228 + u.appURL, 229 + ) 215 230 216 231 return nil 217 232 }