Example #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()
            };
        }
Example #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));
            }
        }