Exemplo n.º 1
0
        public AccountController(IOptions <OpcaoToken> jwtOptions, IUow uow, IClienteRepositorio repository) : base(uow)
        {
            _repository   = repository;
            _tokenOptions = jwtOptions.Value;
            ThrowIfInvalidOptions(_tokenOptions);

            _serializerSettings = new JsonSerializerSettings
            {
                Formatting       = Formatting.Indented,
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };
        }
Exemplo n.º 2
0
        private static void ThrowIfInvalidOptions(OpcaoToken options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (options.ValidFor <= TimeSpan.Zero)
            {
                throw new ArgumentException("O período deve ser maior que zero", nameof(OpcaoToken.ValidFor));
            }

            if (options.SigningCredentials == null)
            {
                throw new ArgumentNullException(nameof(OpcaoToken.SigningCredentials));
            }

            if (options.JtiGenerator == null)
            {
                throw new ArgumentNullException(nameof(OpcaoToken.JtiGenerator));
            }
        }