only allow notification if smtp server is setup.

This commit is contained in:
DESKTOP-GENO133\IvanPlex
2024-01-14 12:13:37 -07:00
parent 7122f4ac0d
commit 6e5cfde2cf
3 changed files with 20 additions and 2 deletions

View File

@@ -32,7 +32,8 @@ namespace CarCareTracker.External.Implementations
using (var db = new LiteDatabase(dbName))
{
var table = db.GetCollection<UserConfigData>(tableName);
return table.Delete(userId);
table.Delete(userId);
return true;
};
}
}

View File

@@ -20,6 +20,10 @@ namespace CarCareTracker.Helper
}
public OperationResponse NotifyUserForRegistration(string emailAddress, string token)
{
if (string.IsNullOrWhiteSpace(mailConfig.EmailServer))
{
return new OperationResponse { Success = false, Message = "SMTP Server Not Setup" };
}
if (string.IsNullOrWhiteSpace(emailAddress) || string.IsNullOrWhiteSpace(token)) {
return new OperationResponse { Success = false, Message = "Email Address or Token is invalid" };
}
@@ -36,6 +40,10 @@ namespace CarCareTracker.Helper
}
public OperationResponse NotifyUserForPasswordReset(string emailAddress, string token)
{
if (string.IsNullOrWhiteSpace(mailConfig.EmailServer))
{
return new OperationResponse { Success = false, Message = "SMTP Server Not Setup" };
}
if (string.IsNullOrWhiteSpace(emailAddress) || string.IsNullOrWhiteSpace(token))
{
return new OperationResponse { Success = false, Message = "Email Address or Token is invalid" };

View File

@@ -1,6 +1,15 @@
@{
ViewData["Title"] = "Admin";
}
@inject IConfiguration config;
@{
bool emailServerIsSetup = true;
var mailConfig = config.GetSection("MailConfig").Get<MailConfig>();
if (mailConfig is null || string.IsNullOrWhiteSpace(mailConfig.EmailServer))
{
emailServerIsSetup = false;
}
}
@model AdminViewModel
<div class="container">
<div class="row">
@@ -22,7 +31,7 @@
</div>
<div class="col-6 d-flex align-items-center">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="enableAutoNotify" checked>
<input class="form-check-input" type="checkbox" role="switch" id="enableAutoNotify" @(emailServerIsSetup ? "checked" : "disabled")>
<label class="form-check-label" for="enableAutoNotify">Auto Notify(via Email)</label>
</div>
</div>