public IActionResult Login([FromBody] Object obj) { // Retrieve actual class of the model var resource = shaper.FormatObject(obj); // Retrieve the resource stored on the database var dbCred = checker.GetCredentialByUsernameValidation(repo.Read(), resource.Username); // Check if username is valid by instance if (dbCred != null) { // Check if password is valid if (crypto.ValidateUser(resource.Password, dbCred.Password)) { // Update password hash dbCred = crypto.EncryptUserPassword(dbCred, resource.Password); repo.Update(dbCred); return(Ok(new { user = dbCred.User })); } } return(Unauthorized("Credentials invalid. Please try again.")); }