]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git/blobdiff - api/api.go
Mails.
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git] / api / api.go
index 79a13a5663fb5f2081458db268a0baefd7ed9731..e01181123633e4a7112dd1124375ae8d7f5e680b 100644 (file)
@@ -8,8 +8,18 @@ import (
 )
 
 var CONFIG Config
+var MAIL_CONFIG MailConfig
+
+type MailConfig struct {
+       IsEnabled   bool
+       SmtpAddress string `toml:"smtp_address"`
+       AddressFrom string `toml:"address_from"`
+       Login       string `toml:"login"`
+       Password    string `toml:"password"`
+}
 
 type Config struct {
+       Domain              string `toml:"domain"`
        JwtSecret           string `toml:"jwt_secret"`
        PasswordResetSecret string `toml:"password_reset_secret"`
        FreeSMSUser         string `toml:"free_sms_user"`
@@ -23,6 +33,15 @@ func SetConfig(config Config) {
        PASSWORD_RESET_SECRET = []byte(config.PasswordResetSecret)
 }
 
+func SetMailConfig(config MailConfig) {
+       MAIL_CONFIG = config
+
+       if config.Login != "" && config.AddressFrom != "" && config.Password != "" && config.SmtpAddress != "" {
+               MAIL_CONFIG.IsEnabled = true
+               ConfigureMailTemplateEngine()
+       }
+}
+
 type Error struct {
        Code        ErrorCode
        UserMessage string