Browse Source

fix: add verifySSL option to mail settings

NGPixel 5 năm trước cách đây
mục cha
commit
2ff0e42c1d

+ 15 - 8
client/components/admin/admin-mail.vue

@@ -26,7 +26,7 @@
                       :label='$t(`admin:mail.senderName`)'
                       required
                       :counter='255'
-                      prepend-icon='mdi-contact-mail'
+                      prepend-icon='mdi-mailbox'
                       )
                     v-text-field(
                       outlined
@@ -34,7 +34,7 @@
                       :label='$t(`admin:mail.senderEmail`)'
                       required
                       :counter='255'
-                      prepend-icon='mdi-at'
+                      prepend-icon='mdi-mailbox'
                       )
                   v-divider
                   .overline.pa-4.grey--text {{ $t('admin:mail.smtp') }}
@@ -66,7 +66,16 @@
                       prepend-icon='mdi-security-network'
                       inset
                       )
-                    v-text-field.mt-3(
+                    v-switch(
+                      v-model='config.verifySSL'
+                      :label='$t(`admin:mail.smtpVerifySSL`)'
+                      color='primary'
+                      persistent-hint
+                      :hint='$t(`admin:mail.smtpVerifySSLHint`)'
+                      prepend-icon='mdi-security-network'
+                      inset
+                      )
+                    v-text-field.mt-8(
                       outlined
                       v-model='config.user'
                       :label='$t(`admin:mail.smtpUser`)'
@@ -79,7 +88,7 @@
                       v-model='config.pass'
                       :label='$t(`admin:mail.smtpPwd`)'
                       required
-                      prepend-icon='mdi-textbox-password'
+                      prepend-icon='mdi-form-textbox-password'
                       type='password'
                       )
 
@@ -147,7 +156,6 @@
 
 <script>
 import _ from 'lodash'
-import { get } from 'vuex-pathify'
 import mailConfigQuery from 'gql/admin/mail/mail-query-config.gql'
 import mailUpdateConfigMutation from 'gql/admin/mail/mail-mutation-save-config.gql'
 import mailTestMutation from 'gql/admin/mail/mail-mutation-sendtest.gql'
@@ -161,6 +169,7 @@ export default {
         host: '',
         port: 0,
         secure: false,
+        verifySSL: false,
         user: '',
         pass: '',
         useDKIM: false,
@@ -172,9 +181,6 @@ export default {
       testLoading: false
     }
   },
-  computed: {
-    darkMode: get('site/dark')
-  },
   methods: {
     async save () {
       try {
@@ -186,6 +192,7 @@ export default {
             host: this.config.host || '',
             port: _.toSafeInteger(this.config.port) || 0,
             secure: this.config.secure || false,
+            verifySSL: this.config.verifySSL || false,
             user: this.config.user || '',
             pass: this.config.pass || '',
             useDKIM: this.config.useDKIM || false,

+ 2 - 0
client/graph/admin/mail/mail-mutation-save-config.gql

@@ -4,6 +4,7 @@ mutation (
   $host: String!,
   $port: Int!,
   $secure: Boolean!,
+  $verifySSL: Boolean!,
   $user: String!,
   $pass: String!,
   $useDKIM: Boolean!,
@@ -18,6 +19,7 @@ mutation (
       host: $host,
       port: $port,
       secure: $secure,
+      verifySSL: $verifySSL,
       user: $user,
       pass: $pass,
       useDKIM: $useDKIM,

+ 1 - 0
client/graph/admin/mail/mail-query-config.gql

@@ -6,6 +6,7 @@
       host
       port
       secure
+      verifySSL
       user
       pass
       useDKIM

+ 4 - 0
server/app/data.yml

@@ -46,6 +46,10 @@ defaults:
     company: ''
     contentLicense: ''
     logoUrl: https://static.requarks.io/logo/wikijs-butterfly.svg
+    mail:
+      host: ''
+      secure: true
+      verifySSL: true
     nav:
       mode: 'MIXED'
     theming:

+ 4 - 1
server/core/mail.js

@@ -13,7 +13,10 @@ module.exports = {
       let conf = {
         host: WIKI.config.mail.host,
         port: WIKI.config.mail.port,
-        secure: WIKI.config.mail.secure
+        secure: WIKI.config.mail.secure,
+        tls: {
+          rejectUnauthorized: !(WIKI.config.mail.verifySSL === false)
+        }
       }
       if (_.get(WIKI.config, 'mail.user', '').length > 1) {
         conf = {

+ 1 - 0
server/graph/resolvers/mail.js

@@ -50,6 +50,7 @@ module.exports = {
           host: args.host,
           port: args.port,
           secure: args.secure,
+          verifySSL: args.verifySSL,
           user: args.user,
           pass: (args.pass === '********') ? WIKI.config.mail.pass : args.pass,
           useDKIM: args.useDKIM,

+ 2 - 0
server/graph/schemas/mail.graphql

@@ -33,6 +33,7 @@ type MailMutation {
     host: String!
     port: Int!
     secure: Boolean!
+    verifySSL: Boolean!
     user: String!
     pass: String!
     useDKIM: Boolean!
@@ -52,6 +53,7 @@ type MailConfig {
   host: String!
   port: Int!
   secure: Boolean!
+  verifySSL: Boolean!
   user: String!
   pass: String!
   useDKIM: Boolean!

+ 1 - 0
server/setup.js

@@ -104,6 +104,7 @@ module.exports = () => {
         host: '',
         port: 465,
         secure: true,
+        verifySSL: true,
         user: '',
         pass: '',
         useDKIM: false,