1
0
mirror of https://github.com/bitwarden/server.git synced 2025-01-22 21:51:22 +01:00

use SettingHasValue for smtp services

This commit is contained in:
Kyle Spearrin 2019-08-07 19:39:37 -04:00
parent 5f4c7eb122
commit 6d4e34b229
2 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,6 @@
using System;
using System.Threading.Tasks;
using Bit.Core.Utilities;
using MailKit.Net.Smtp;
using Microsoft.Extensions.Logging;
using MimeKit;
@ -80,8 +81,8 @@ namespace Bit.Core.Services
await client.ConnectAsync(_globalSettings.Mail.Smtp.Host, _globalSettings.Mail.Smtp.Port, useSsl);
}
if(!string.IsNullOrWhiteSpace(_globalSettings.Mail.Smtp.Username) &&
!string.IsNullOrWhiteSpace(_globalSettings.Mail.Smtp.Password))
if(CoreHelpers.SettingHasValue(_globalSettings.Mail.Smtp.Username) &&
CoreHelpers.SettingHasValue(_globalSettings.Mail.Smtp.Password))
{
await client.AuthenticateAsync(_globalSettings.Mail.Smtp.Username,
_globalSettings.Mail.Smtp.Password);

View File

@ -4,6 +4,7 @@ using System.Net.Mail;
using System.Net;
using System.Text;
using Microsoft.Extensions.Logging;
using Bit.Core.Utilities;
namespace Bit.Core.Services
{
@ -38,10 +39,10 @@ namespace Bit.Core.Services
client.UseDefaultCredentials = _globalSettings.Mail.Smtp.UseDefaultCredentials;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
if(!string.IsNullOrWhiteSpace(_globalSettings.Mail.Smtp.Username) &&
!string.IsNullOrWhiteSpace(_globalSettings.Mail.Smtp.Password))
if(CoreHelpers.SettingHasValue(_globalSettings.Mail.Smtp.Username) &&
CoreHelpers.SettingHasValue(_globalSettings.Mail.Smtp.Password))
{
if(!string.IsNullOrWhiteSpace(_globalSettings.Mail.Smtp.AuthType))
if(CoreHelpers.SettingHasValue(_globalSettings.Mail.Smtp.AuthType))
{
var cred = new NetworkCredential(_globalSettings.Mail.Smtp.Username,
_globalSettings.Mail.Smtp.Password);