/*
* Copyright (c) Akveo 2019. All Rights Reserved.
* Licensed under the Personal / Commercial License.
* See LICENSE_PERSONAL / LICENSE_COMMERCIAL in the project root for license information on type of purchased license.
*/

namespace Common.WebApi.Identity
{
    public class AuthResult
    {
        private AuthResult(string token)
        {
            Succeeded = true;
            IsModelValid = true;
            Token = token;
        }

        private AuthResult(bool isSucceeded, bool isModelValid)
        {
            Succeeded = isSucceeded;
            IsModelValid = isModelValid;
        }

        private AuthResult(bool isSucceeded)
        {
            Succeeded = isSucceeded;
            IsModelValid = isSucceeded;
        }

        public bool Succeeded { get; }
        public string Token { get; }
        public bool IsModelValid { get; }

        public static AuthResult UnvalidatedResult => new AuthResult(false);
        public static AuthResult UnauthorizedResult => new AuthResult(false, true);
        public static AuthResult SucceededResult => new AuthResult(true);
        public static AuthResult TokenResult(string token)
        {
            return new AuthResult(token);
        }
    }
}