Skip to content
Snippets Groups Projects
Commit fc0a1045 authored by Petar Hristov's avatar Petar Hristov :speech_balloon:
Browse files

Fix: Kleinigkeiten (coscine/issues#1294)

parent c4f210d1
Branches
No related tags found
1 merge request!120New: Add the Contact Changing functionality to the database and backend
......@@ -24,15 +24,21 @@ namespace Coscine.Database.Models
IEnumerable<ContactChange> emailData = GetAllWhere((contactChange) => contactChange.UserId == userId);
// Return True if entries for a user exist inside the database table ContactChange. Else return False.
if (emailData.Count() > 0)
{
return true;
}
else
{
return false;
}
}
public ContactChangeObject NewEmailChangeRequest(Guid userId, string email)
{
if (UserHasEmailsToConfirm(userId))
{
DeleteAllDbEntries(userId); // <--- REMOVE THIS LINE IF YOU WANT TO KEEP HISTORY OF EMAIL CHANGES.
}
ContactChangeObject contactChangeObject = AddDbEntry(userId, email);
// Sending a confirmation email after an addition to the database is handled by the Controller.
return contactChangeObject;
......@@ -43,7 +49,9 @@ namespace Coscine.Database.Models
List<ContactChangeObject> contactChangeObjects = new List<ContactChangeObject>();
IEnumerable<ContactChange> emailData = GetAllWhere((contactChange) => contactChange.UserId == userId);
foreach (var entry in emailData)
{
contactChangeObjects.Add(ToObject(entry));
}
return contactChangeObjects;
}
......@@ -72,20 +80,17 @@ namespace Coscine.Database.Models
}
else
{
// EXPIRED
throw new Exception("EXPIRED: Token " + token.ToString() + " has expired.");
}
}
else
{
// INVALID (null EditDate)
throw new ArgumentNullException("INVALID: Value EditDate is NULL for Token " + token.ToString() + ".");
}
}
else
{
// INVALID (token-user combination not in Database)
throw new MissingFieldException("INVALID: The Token " + token.ToString() + " is not valid. No entry inside the Database.");
}
}
......@@ -101,7 +106,9 @@ namespace Coscine.Database.Models
// Token EXPIRED when expirationDateTime = -1 (Expiration is BEFORE Now)
// Token VALID when expirationDateTime = 0 OR = 1 (Expiration IS Now or AFTER Now)
if (compareDateTime < 0)
{
Delete(entry);
}
}
}
......@@ -109,7 +116,9 @@ namespace Coscine.Database.Models
{
IEnumerable<ContactChange> emailData = GetAllWhere((contactChange) => contactChange.UserId == userId);
foreach (var entry in emailData)
{
Delete(entry);
}
}
private ContactChangeObject AddDbEntry(Guid userId, string email)
......
......@@ -58,8 +58,6 @@ namespace Coscine.Database.DataModel
{
if (!optionsBuilder.IsConfigured)
{
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
optionsBuilder.UseSqlServer("Data Source=d-db-d02\\mssql14;Integrated Security=False;User ID=coscineDev;Password=Dev#123;Database=Coscine_hp-admin ");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment