예제 #1
0
        public ActionResult Domain()
        {
            var identity = HttpContext.GetIdentity();

            if (identity.IsAuthenticated)
            {
                var state             = identity.SystemState;
                var shopifyConnection = _connectionRepository.Retrieve();

                var model = new ShopifyDomainModel();
                model.IsWizardMode       = !state.IsRandomAccessMode;
                model.IsConnectionBroken = state.ShopifyConnState.IsBroken();
                model.CanEditShopifyUrl  = !state.IsShopifyUrlFinalized();
                model.ShopDomain         = shopifyConnection.ShopifyDomain;

                return(View(model));
            }
            else
            {
                var model = new ShopifyDomainModel();
                model.IsWizardMode       = true;
                model.IsConnectionBroken = false;
                model.CanEditShopifyUrl  = true;
                model.ShopDomain         = "";

                return(View(model));
            }
        }
예제 #2
0
        public ActionResult AcumaticaCredentials()
        {
            var tenant = _connectionRepository.Retrieve();

            var model = new AcumaticaCredentialsModel()
            {
                InstanceUrl = tenant.AcumaticaInstanceUrl,
                Branch      = tenant.AcumaticaBranch,
                Company     = tenant.AcumaticaCompanyName,
            };

            return(new JsonNetResult(model));
        }
예제 #3
0
        private async Task <string> GetAccessTokenAsync()
        {
            var credentials = _credentialsRepository.Retrieve();

            if (credentials != null && !string.IsNullOrEmpty(credentials.AccessToken) && credentials.CreateDate.AddSeconds(credentials.ExpiresIn - 10) > DateTime.UtcNow)
            {
                return($"{credentials.TokenType} {credentials.AccessToken}");
            }

            var credentialsId = credentials?.Id;

            switch (_configs["AuthorizationMode"])
            {
            case "InitialConfiguration":
            {
                // IMPORTANT! Use: GetSpotifyAccessTokenCode.html

                credentials = await CreateCredentialsAsync();

                _logger.LogCritical("{Method} Write the following refresh token value to the AppSettings:Spotify:RefreshToken: {RefreshToken}",
                                    MethodBase.GetCurrentMethod().Name, credentials.RefreshToken); // Write this to the RefreshToken field in config file!!!
                break;
            }

            case "RefreshToken":
            {
                credentials = await RefreshCredentialsAsync();

                break;
            }

            default:
            {
                throw new Exception($"{MethodBase.GetCurrentMethod().Name} Invalid AuthorizationMode: {_configs["AuthorizationMode"]} Check settings!");
            }
            }

            credentials.Id = credentialsId;
            _credentialsRepository.Register(credentials);

            return($"{credentials.TokenType} {credentials.AccessToken}");
        }