.NETCore has changed things. So to return a failed result where you assign your own errors you would have to create a fully qualified IdentityError
instance for each error you want to pass.
Let's say for example you have the following errors and you want to returl a failed result with those errors:
var errors1 = "Your password is incorrect";
var errors2 = "Your email is not recognized";
To proceed and return a failed address for with these errors, you would do the following:
var result = IdentityResult.Failed(
new IdentityError[] {
new IdentityError{
Code = "0001",
Description = error1
},
new IdentityError{
Code = "0002",
Description = error2
}
}
);
Basically what's happeneing here is that the new Failed
method of the IdentityResult
expects params
as IdentityError[]
. Obviously, if you had many errors you'd create an IdentityError[]
variable and then put all your errors in and then pass it to your Failed
method.
IdentityResult.Failed(msgs.ToArray())
. – Chew