Handling mit Support PIN verbessert
- 7 Tage statt 3 Tage Zeit bis zur Aktivierung. Dann 24h bis sie verfällt - Trim um Leerzeichen zu entfernen ***** aus Support Mail mit PIN ersetzt
This commit is contained in:
@@ -94,31 +94,41 @@ namespace BeWo.Service.ServiceImplementations
|
||||
|
||||
public bool SendEMailWithSender(string senderName, string senderEMail, string subject, string body)
|
||||
{
|
||||
if (subject == "FEHLERMELDUNG" && body.Contains("Kontaktdaten:"))
|
||||
if (subject == "FEHLERMELDUNG")
|
||||
{
|
||||
int start = body.IndexOf("Kontaktdaten:") + "Kontaktdaten:".Length;
|
||||
|
||||
int stop = body.IndexOf("\n", start);
|
||||
|
||||
if (stop > start)
|
||||
if (body.Contains("Kontaktdaten:"))
|
||||
{
|
||||
String address = body.Substring(start, stop - start).Trim();
|
||||
int start = body.IndexOf("Kontaktdaten:") + "Kontaktdaten:".Length;
|
||||
|
||||
if (address.Contains("@"))
|
||||
int stop = body.IndexOf("\n", start);
|
||||
|
||||
if (stop > start)
|
||||
{
|
||||
try
|
||||
{
|
||||
var addr = new System.Net.Mail.MailAddress(address);
|
||||
senderEMail = addr.Address;
|
||||
}
|
||||
catch
|
||||
{
|
||||
//Ignore
|
||||
}
|
||||
String address = body.Substring(start, stop - start).Trim();
|
||||
|
||||
|
||||
if (address.Contains("@"))
|
||||
{
|
||||
try
|
||||
{
|
||||
var addr = new System.Net.Mail.MailAddress(address);
|
||||
senderEMail = addr.Address;
|
||||
}
|
||||
catch
|
||||
{
|
||||
//Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (body.Contains("PIN: *****"))
|
||||
{
|
||||
var pin = UserServiceImp.GeneratePIN(5);
|
||||
|
||||
if (!String.IsNullOrEmpty(pin))
|
||||
{
|
||||
body = body.Replace("PIN: *****", "PIN: " + pin);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
try
|
||||
{
|
||||
if (checkTenant && !TenantExists())
|
||||
if (checkTenant && !TenantExists())
|
||||
{
|
||||
return UserValidationResult.TenantUnknown;
|
||||
//return Membership.ValidateUser(pUserName, pPassword);
|
||||
@@ -429,11 +429,6 @@ namespace BeWo.Service.ServiceImplementations
|
||||
}
|
||||
String pin = pPIN;
|
||||
|
||||
if (!String.IsNullOrEmpty(pin))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ApplicationUser bsUser = DAOFactory.UserDAO.GetBSUser(pUserName, pPassword);
|
||||
|
||||
if (bsUser != null && pUserName != "BSAdmin")
|
||||
@@ -465,7 +460,7 @@ namespace BeWo.Service.ServiceImplementations
|
||||
|
||||
if (!String.IsNullOrEmpty(pPIN) && pPIN.IndexOf('_') >= 0)
|
||||
{
|
||||
pin = pPIN.Substring(0, pPIN.IndexOf('_'));
|
||||
pin = pPIN.Substring(0, pPIN.IndexOf('_')).Trim();
|
||||
computerName = pPIN.Substring(pPIN.IndexOf('_') + 1);
|
||||
}
|
||||
var pins = DAOFactory.GenericDAO.GetAll<SupportPin>();
|
||||
@@ -479,7 +474,7 @@ namespace BeWo.Service.ServiceImplementations
|
||||
else
|
||||
{
|
||||
supportPIN = y[0];
|
||||
if (supportPIN.ExpirationDate < DateTime.Now)
|
||||
if ((supportPIN.ExpirationDate < DateTime.Now) || (supportPIN.UsingDate.HasValue && supportPIN.UsingDate.Value.AddDays(1) < DateTime.Now))
|
||||
{
|
||||
//if (supportPIN.IsUsed.HasValue && supportPIN.IsUsed.Value)
|
||||
// result = UserValidationResult.PinAlreadyUsed;
|
||||
@@ -844,7 +839,7 @@ namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
try
|
||||
{
|
||||
//pSupportPin.ExpirationDate = DateTime.Now.AddDays(3);
|
||||
pSupportPin.ExpirationDate = DateTime.Now.AddDays(7);
|
||||
|
||||
var lSupportPin = MapperFactory.SupportPinDC_SupportPin.MapToNewEntity(pSupportPin);
|
||||
DAOFactory.GenericDAO.Insert(lSupportPin);
|
||||
@@ -859,6 +854,25 @@ namespace BeWo.Service.ServiceImplementations
|
||||
}
|
||||
}
|
||||
|
||||
public static string GeneratePIN(int maxSize = 5)
|
||||
{
|
||||
var random = new Random();
|
||||
string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
var pinStr = new string(Enumerable.Repeat(chars, maxSize).Select(s => s[random.Next(s.Length)]).ToArray());
|
||||
var pin = new SupportPin
|
||||
{
|
||||
Pin = pinStr,
|
||||
IsUsed = false,
|
||||
CreationDate = DateTime.Now
|
||||
};
|
||||
pin.ExpirationDate = pin.CreationDate.Value.AddDays(7);
|
||||
|
||||
DAOFactory.GenericDAO.Insert(pin);
|
||||
|
||||
return pinStr;
|
||||
}
|
||||
|
||||
public List<SupportPinDC> GetAllSupportPins()
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user