Ejemplo n.º 1
0
        public async Task <IHttpActionResult> Register(LoginViewModel userModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await authRepository.Create(userModel);

            if (HasErrors(result))
            {
                return(BadRequest(ModelState));
            }

            return(Ok());
        }
        public void GetById_Null()
        {
            // Init
            var repo = new AuthorizationRepository();

            // Create authz
            var authz = repo.Create();

            authz.Identifier.Type  = "dns";
            authz.Identifier.Value = "some.test.com";
            authz.Status           = AuthorizationStatus.Pending;
            repo.Add(authz);

            // Get authz by Id
            var authz2 = repo.GetById(9); // wrong id

            Assert.Null(authz2);
        }
        /// <inheritdoc/>
        public virtual IAuthorization Create(int accountId, Identifier identifier)
        {
            // Create Authorization
            var authz = AuthorizationRepository.Create();

            // Fill params
            OnCreateParams(authz, accountId, identifier);

            // Save authorization
            var addedAuthz = AuthorizationRepository.Add(authz);

            // Add challenges
            var http = ChallengeService.Create(addedAuthz.Id, "http-01");

            //var tls = ChallengeService.Create(addedAuthz.Id, "tls-01");
            //var dns = ChallengeService.Create(addedAuthz.Id, "dns-01");

            Logger.Info("Authorization {id} created", authz.Id);

            return(addedAuthz);
        }