public async Task <DropshipAccount> SetupAccount(DropshipAccountConfiguration account, string username)
        {
            var dropshipAccount = new DropshipAccount()
            {
                Username     = username,
                Status       = AccountStatus.Existing,
                Subscription = account.Subscription
            };

            await dbAccounts.CreateAccount(dropshipAccount);

            return(dropshipAccount);
        }
        public async Task <IActionResult> CreateAccount([FromBody] DropshipAccountConfiguration config, [FromServices] IUserService user)
        {
            if (config.Subscription.EmptyOrNull())
            {
                return(NotFound());
            }

            var username = "******";

            if (HttpContext.User.Identity.IsAuthenticated)
            {
                username = HttpContext.User.Identity.Name;
            }

            var account = await dropship.SetupAccount(config, username);

            HttpContext.Response.Headers.Add("X-USER-TOKEN", user.CreateJWT(new UserLoginModel()
            {
                Username = username
            }, account));                                                                                                            //Update user JWT with dropshipping authentication

            return(Ok());
        }
Exemple #3
0
        public async Task <IActionResult> Dropshipping(DropshipAccountConfiguration config)
        {
            await dropship.SetupAccount(config);

            return(LocalRedirect("/dropship"));
        }