// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.Identity
{
///
/// Service to enable localization for application facing identity errors.
///
///
/// These errors are returned to controllers and are generally used as display messages to end users.
///
public class IdentityErrorDescriber
{
///
/// Returns the default .
///
/// The default .
public virtual IdentityError DefaultError()
{
return new IdentityError
{
Code = nameof(DefaultError),
Description = Resources.DefaultError
};
}
///
/// Returns an indicating a concurrency failure.
///
/// An indicating a concurrency failure.
public virtual IdentityError ConcurrencyFailure()
{
return new IdentityError
{
Code = nameof(ConcurrencyFailure),
Description = Resources.ConcurrencyFailure
};
}
///
/// Returns an indicating a password mismatch.
///
/// An indicating a password mismatch.
public virtual IdentityError PasswordMismatch()
{
return new IdentityError
{
Code = nameof(PasswordMismatch),
Description = Resources.PasswordMismatch
};
}
///
/// Returns an indicating an invalid token.
///
/// An indicating an invalid token.
public virtual IdentityError InvalidToken()
{
return new IdentityError
{
Code = nameof(InvalidToken),
Description = Resources.InvalidToken
};
}
///
/// Returns an indicating a recovery code was not redeemed.
///
/// An indicating a recovery code was not redeemed.
public virtual IdentityError RecoveryCodeRedemptionFailed()
{
return new IdentityError
{
Code = nameof(RecoveryCodeRedemptionFailed),
Description = Resources.RecoveryCodeRedemptionFailed
};
}
///
/// Returns an indicating an external login is already associated with an account.
///
/// An indicating an external login is already associated with an account.
public virtual IdentityError LoginAlreadyAssociated()
{
return new IdentityError
{
Code = nameof(LoginAlreadyAssociated),
Description = Resources.LoginAlreadyAssociated
};
}
///
/// Returns an indicating the specified user is invalid.
///
/// The user name that is invalid.
/// An indicating the specified user is invalid.
public virtual IdentityError InvalidUserName(string userName)
{
return new IdentityError
{
Code = nameof(InvalidUserName),
Description = Resources.FormatInvalidUserName(userName)
};
}
///
/// Returns an indicating the specified is invalid.
///
/// The email that is invalid.
/// An indicating the specified is invalid.
public virtual IdentityError InvalidEmail(string email)
{
return new IdentityError
{
Code = nameof(InvalidEmail),
Description = Resources.FormatInvalidEmail(email)
};
}
///
/// Returns an indicating the specified already exists.
///
/// The user name that already exists.
/// An indicating the specified already exists.
public virtual IdentityError DuplicateUserName(string userName)
{
return new IdentityError
{
Code = nameof(DuplicateUserName),
Description = Resources.FormatDuplicateUserName(userName)
};
}
///
/// Returns an indicating the specified is already associated with an account.
///
/// The email that is already associated with an account.
/// An indicating the specified is already associated with an account.
public virtual IdentityError DuplicateEmail(string email)
{
return new IdentityError
{
Code = nameof(DuplicateEmail),
Description = Resources.FormatDuplicateEmail(email)
};
}
///
/// Returns an indicating the specified name is invalid.
///
/// The invalid role.
/// An indicating the specific role name is invalid.
public virtual IdentityError InvalidRoleName(string role)
{
return new IdentityError
{
Code = nameof(InvalidRoleName),
Description = Resources.FormatInvalidRoleName(role)
};
}
///
/// Returns an indicating the specified name already exists.
///
/// The duplicate role.
/// An indicating the specific role name already exists.
public virtual IdentityError DuplicateRoleName(string role)
{
return new IdentityError
{
Code = nameof(DuplicateRoleName),
Description = Resources.FormatDuplicateRoleName(role)
};
}
///
/// Returns an indicating a user already has a password.
///
/// An indicating a user already has a password.
public virtual IdentityError UserAlreadyHasPassword()
{
return new IdentityError
{
Code = nameof(UserAlreadyHasPassword),
Description = Resources.UserAlreadyHasPassword
};
}
///
/// Returns an indicating user lockout is not enabled.
///
/// An indicating user lockout is not enabled..
public virtual IdentityError UserLockoutNotEnabled()
{
return new IdentityError
{
Code = nameof(UserLockoutNotEnabled),
Description = Resources.UserLockoutNotEnabled
};
}
///
/// Returns an indicating a user is already in the specified .
///
/// The duplicate role.
/// An indicating a user is already in the specified .
public virtual IdentityError UserAlreadyInRole(string role)
{
return new IdentityError
{
Code = nameof(UserAlreadyInRole),
Description = Resources.FormatUserAlreadyInRole(role)
};
}
///
/// Returns an indicating a user is not in the specified .
///
/// The duplicate role.
/// An indicating a user is not in the specified .
public virtual IdentityError UserNotInRole(string role)
{
return new IdentityError
{
Code = nameof(UserNotInRole),
Description = Resources.FormatUserNotInRole(role)
};
}
///
/// Returns an indicating a password of the specified does not meet the minimum length requirements.
///
/// The length that is not long enough.
/// An indicating a password of the specified does not meet the minimum length requirements.
public virtual IdentityError PasswordTooShort(int length)
{
return new IdentityError
{
Code = nameof(PasswordTooShort),
Description = Resources.FormatPasswordTooShort(length)
};
}
///
/// Returns an indicating a password does not meet the minimum number of unique chars.
///
/// The number of different chars that must be used.
/// An indicating a password does not meet the minimum number of unique chars.
public virtual IdentityError PasswordRequiresUniqueChars(int uniqueChars)
{
return new IdentityError
{
Code = nameof(PasswordRequiresUniqueChars),
Description = Resources.FormatPasswordRequiresUniqueChars(uniqueChars)
};
}
///
/// Returns an indicating a password entered does not contain a non-alphanumeric character, which is required by the password policy.
///
/// An indicating a password entered does not contain a non-alphanumeric character.
public virtual IdentityError PasswordRequiresNonAlphanumeric()
{
return new IdentityError
{
Code = nameof(PasswordRequiresNonAlphanumeric),
Description = Resources.PasswordRequiresNonAlphanumeric
};
}
///
/// Returns an indicating a password entered does not contain a numeric character, which is required by the password policy.
///
/// An indicating a password entered does not contain a numeric character.
public virtual IdentityError PasswordRequiresDigit()
{
return new IdentityError
{
Code = nameof(PasswordRequiresDigit),
Description = Resources.PasswordRequiresDigit
};
}
///
/// Returns an indicating a password entered does not contain a lower case letter, which is required by the password policy.
///
/// An indicating a password entered does not contain a lower case letter.
public virtual IdentityError PasswordRequiresLower()
{
return new IdentityError
{
Code = nameof(PasswordRequiresLower),
Description = Resources.PasswordRequiresLower
};
}
///
/// Returns an indicating a password entered does not contain an upper case letter, which is required by the password policy.
///
/// An indicating a password entered does not contain an upper case letter.
public virtual IdentityError PasswordRequiresUpper()
{
return new IdentityError
{
Code = nameof(PasswordRequiresUpper),
Description = Resources.PasswordRequiresUpper
};
}
}
}