only allow notification if smtp server is setup.
This commit is contained in:
@@ -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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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" };
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user