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

Fix: Removed UserID reference from ExecuteConfirmation method (coscine/issues#1294)

parent 33b3f856
No related branches found
No related tags found
1 merge request!120New: Add the Contact Changing functionality to the database and backend
......@@ -47,9 +47,9 @@ namespace Coscine.Database.Models
return contactChangeObjects;
}
public UserObject ExecuteConfirmation(Guid userId, Guid token)
public UserObject ExecuteConfirmation(Guid token)
{
ContactChange emailData = GetWhere((contactChange) => contactChange.UserId == userId && contactChange.ConfirmationToken == token);
ContactChange emailData = GetWhere((contactChange) => contactChange.ConfirmationToken == token);
if (emailData != null)
{
if (emailData.EditDate != null)
......@@ -63,30 +63,30 @@ namespace Coscine.Database.Models
{
// VALID
UserModel userModel = new UserModel();
User user = userModel.GetById(userId);
User user = userModel.GetById(emailData.UserId);
user.EmailAddress = emailData.NewEmail; // Overwrite old Email with New.
userModel.Update(user); // Update Database (User Table).
Delete(emailData); // Delete Entry from Database (ContactChange Table).
UserObject userObject = userModel.CreateReturnObjectFromDatabaseObject(userModel.GetWhere((usr) => usr.Id == userId));
UserObject userObject = userModel.CreateReturnObjectFromDatabaseObject(userModel.GetWhere((usr) => usr.Id == emailData.UserId));
return userObject;
}
else
{
// EXPIRED
throw new Exception("EXPIRED: Token " + token.ToString() + " for User with an ID " + userId.ToString() + " has 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() + " and User with an ID " + userId.ToString() + ".");
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() + " and User with an ID " + userId.ToString() + " combination is not valid. No entry inside the Database.");
throw new MissingFieldException("INVALID: The Token " + token.ToString() + " is not valid. No entry inside the Database.");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment