public async Task <IActionResult> ConfirmEmail([FromQuery] EmailQuery query)
        {
            if (query.Email == null || query.Code == null)
            {
                return(BadRequest(new AuthFailedResponse
                {
                    Errors = new[] { "Data is incorrect." }
                }));
            }

            var authenticationResult = await _identityService.ConfirmEmailAsync(query.Email, query.Code);

            if (!authenticationResult.IsSuccessful)
            {
                return(BadRequest(new AuthFailedResponse
                {
                    Errors = authenticationResult.Errors
                }));
            }

            return(Ok(new AuthSuccessfulResponse
            {
                Token = authenticationResult.Token,
                RefreshToken = authenticationResult.RefreshToken,
                Message = "Your mail has been successfully confirmed."
            }));
        }
Beispiel #2
0
        public void Run()
        {
            var movie      = Guid.NewGuid();
            var emailQuery = new EmailQuery("*****@*****.**");

            Console.WriteLine($"Is customer: {new IsCustomerQueryHandler().Handle(emailQuery)}");

            Console.WriteLine("Press enter to become customer");
            Run(() => _becomeCustomerCommandHandler.Handle(new BecomeCustomerCommand("*****@*****.**", "wozzaa")));

            Console.WriteLine($"Is customer: {new IsCustomerQueryHandler().Handle(emailQuery)}");
            Console.WriteLine($"Has subscription: {new HasSubscriptionQueryHandler().Handle(emailQuery)}");

            Console.WriteLine("Press enter to start subscription");
            Run(() => _startSubscriptionCommandHandler.Handle(new StartSubscriptionCommand("*****@*****.**")));

            Console.WriteLine(
                $"Can view movie: {new CanViewQueryHandler().Handle(new PayPerViewQuery("*****@*****.**", movie))}");

            Console.WriteLine("Press enter to purchase PPW");
            Run(() => _purchasePpwCommandHandler.Handle(new PurchasePayPerViewCommand("*****@*****.**", movie)));

            Console.WriteLine("Press enter to add credit card");
            Run(() => _addCreditcardCommandHandler.Handle(new AddCreditCardCommand("*****@*****.**",
                                                                                   "9999-5555-3333-1111")));

            Console.WriteLine("Press enter to promote credit card");
            Run(() => _promoteCreditCardCommandHandler.Handle(
                    new PromoteCreditCardAsPrimaryCommand("*****@*****.**", "9999-5555-3333-1111")));

            Console.WriteLine("Press enter to start subscription");
            Run(() => _startSubscriptionCommandHandler.Handle(new StartSubscriptionCommand("*****@*****.**")));

            Console.WriteLine($"Has subscription: {new HasSubscriptionQueryHandler().Handle(emailQuery)}");

            Console.WriteLine("Press enter to purchase PPW");
            Run(() => _purchasePpwCommandHandler.Handle(new PurchasePayPerViewCommand("*****@*****.**", movie)));

            Console.WriteLine(
                $"Can view movie: {new CanViewQueryHandler().Handle(new PayPerViewQuery("*****@*****.**", movie))}");

            Console.WriteLine("Press enter to add another credit card");
            Run(() => _addCreditcardCommandHandler.Handle(new AddCreditCardCommand("*****@*****.**",
                                                                                   "1111-2222-3333-1111")));

            Console.WriteLine("Press enter to promote credit card");
            Run(() => _promoteCreditCardCommandHandler.Handle(
                    new PromoteCreditCardAsPrimaryCommand("*****@*****.**", "1111-2222-3333-1111")));

            Console.WriteLine("Press enter to remove credit card");
            Run(() => _removeCreditCardCommandHandler.Handle(new RemoveCreditCardCommand("*****@*****.**",
                                                                                         "9999-5555-3333-1111")));

            Console.WriteLine("Press enter to see event stack");
            Run(() => Console.WriteLine(string.Join(Environment.NewLine,
                                                    EventStore.GetHistory().Select(x => $"{x.Timestamp} : {x.GetType().Name.Replace("Event", string.Empty)}"))));
        }
Beispiel #3
0
 public void OnGet()
 {
     Model = _messageManager.Load(Model);
 }