diff options
author | jloup <jeanloup.jamet@gmail.com> | 2018-05-11 13:57:29 +0200 |
---|---|---|
committer | jloup <jeanloup.jamet@gmail.com> | 2018-05-11 13:57:29 +0200 |
commit | 2da5b12c31074591eaf16929b760322b98f189e8 (patch) | |
tree | 407b699688edddca381ca80e5ecea9458d748cc1 /api/api.go | |
parent | 299b6b6d9fb879c06e675ef240f361348629ff6c (diff) | |
download | Front-2da5b12c31074591eaf16929b760322b98f189e8.tar.gz Front-2da5b12c31074591eaf16929b760322b98f189e8.tar.zst Front-2da5b12c31074591eaf16929b760322b98f189e8.zip |
Mails.
Diffstat (limited to 'api/api.go')
-rw-r--r-- | api/api.go | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -8,8 +8,18 @@ import ( | |||
8 | ) | 8 | ) |
9 | 9 | ||
10 | var CONFIG Config | 10 | var CONFIG Config |
11 | var MAIL_CONFIG MailConfig | ||
12 | |||
13 | type MailConfig struct { | ||
14 | IsEnabled bool | ||
15 | SmtpAddress string `toml:"smtp_address"` | ||
16 | AddressFrom string `toml:"address_from"` | ||
17 | Login string `toml:"login"` | ||
18 | Password string `toml:"password"` | ||
19 | } | ||
11 | 20 | ||
12 | type Config struct { | 21 | type Config struct { |
22 | Domain string `toml:"domain"` | ||
13 | JwtSecret string `toml:"jwt_secret"` | 23 | JwtSecret string `toml:"jwt_secret"` |
14 | PasswordResetSecret string `toml:"password_reset_secret"` | 24 | PasswordResetSecret string `toml:"password_reset_secret"` |
15 | FreeSMSUser string `toml:"free_sms_user"` | 25 | FreeSMSUser string `toml:"free_sms_user"` |
@@ -23,6 +33,15 @@ func SetConfig(config Config) { | |||
23 | PASSWORD_RESET_SECRET = []byte(config.PasswordResetSecret) | 33 | PASSWORD_RESET_SECRET = []byte(config.PasswordResetSecret) |
24 | } | 34 | } |
25 | 35 | ||
36 | func SetMailConfig(config MailConfig) { | ||
37 | MAIL_CONFIG = config | ||
38 | |||
39 | if config.Login != "" && config.AddressFrom != "" && config.Password != "" && config.SmtpAddress != "" { | ||
40 | MAIL_CONFIG.IsEnabled = true | ||
41 | ConfigureMailTemplateEngine() | ||
42 | } | ||
43 | } | ||
44 | |||
26 | type Error struct { | 45 | type Error struct { |
27 | Code ErrorCode | 46 | Code ErrorCode |
28 | UserMessage string | 47 | UserMessage string |