/* * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ using Microsoft.AspNetCore.Identity; namespace Amazon.AspNetCore.Identity.Cognito { public class CognitoSignInResult : SignInResult { /// /// Returns a CognitoSignInResult that represents a required password change. /// /// A CognitoSignInResult that represents a required password change. public static readonly CognitoSignInResult PasswordChangeRequired = new CognitoSignInResult { RequiresPasswordChange = true }; /// /// Returns a CognitoSignInResult that represents a required password reset. /// /// A CognitoSignInResult that represents a required password reset. public static readonly CognitoSignInResult PasswordResetRequired = new CognitoSignInResult { RequiresPasswordReset = true }; /// /// Returns a flag indication whether changing the password is required. /// /// A flag indication whether changing the password is required. public bool RequiresPasswordChange { get; protected set; } /// /// Returns a flag indication whether reseting the password is required. /// /// A flag indication whether reseting the password is required. public bool RequiresPasswordReset { get; protected set; } /// /// Converts the value of the current object to its equivalent string representation. /// /// A string representation of value of the current object. public override string ToString() { return IsLockedOut ? "Lockedout" : IsNotAllowed ? "NotAllowed" : RequiresTwoFactor ? "RequiresTwoFactor" : RequiresPasswordChange ? "RequiresPasswordChange" : RequiresPasswordReset ? "RequiresPasswordReset" : Succeeded ? "Succeeded" : "Failed"; } } public static class SigninResultExtensions { public static bool IsCognitoSignInResult(this SignInResult result) { return result is CognitoSignInResult; } } }