Example #1
0
        public IActionResult CreateSession(string zone)
        {
            var zoneModel = _zones.Single(s => s.LocalPath.Equals(zone, StringComparison.CurrentCultureIgnoreCase));

            if (zoneModel == null)
            {
                return(RedirectToAction(nameof(Error), new { message = $"Could not find Zone for \"zone\"" }));
            }

            var model = new SNWLExternalAuthenticationRedirectModel
            {
                SessionId         = Guid.NewGuid().ToString(),
                MAC               = FakeDataGenerator.GenerateMACAddress(),
                IP                = FakeDataGenerator.GenerateRandomIp(),
                Ufi               = "0006010203",
                SSID              = "",
                req               = "http://www.github.com",
                ClientRedirectUrl = zoneModel.SNWLRedirectEndpointURL,
                MgmtBaseUrl       = _appSettings.ManagementBaseUrl
            };

            // keep track of generated models for session sync
            _stateProvider.AddGeneratedSession(model.Map(zoneModel));

            var fullUrl = string.Concat(_settings.GetLoginPage(zoneModel.LocalPath), buildQueryString(model));

            _logger.LogInformation($"Redirect user to: {fullUrl}");

            return(Redirect(fullUrl));
        }