Example #1
0
        public void Activate()
        {
            if (string.IsNullOrEmpty(Secret))
            {
                throw new EntityValidationException("Secret must be provided before client can be activated!");
            }

            if (string.IsNullOrEmpty(Name))
            {
                throw new EntityValidationException("Name must be provided before client can be activated!");
            }

            if (_uris.All(u => u.Type != ClientUriType.Redirect))
            {
                throw new EntityValidationException("At least one Redirect URI must be provided before client can be activated!");
            }

            if (!_allowedGrantTypes.Any())
            {
                throw new EntityValidationException("At least one allowed grant type is must be provided before client can be activated!");
            }

            var e = new ClientActivatedEvent()
            {
                ClientId   = Id,
                OccurredOn = DateTime.UtcNow
            };

            _changes.Add(e);
            EventHandler.Activated(this, e);
        }
Example #2
0
 public static Client Activated(Client client, ClientActivatedEvent e)
 {
     client.Active = true;
     return(client);
 }