Пример #1
0
        public void SetSettings(RedirectSettings settings)
        {
            var settingsPart = _orchardServices.WorkContext.CurrentSite.As <RedirectSettingsPart>();

            settingsPart.Rules   = settings.Rules;
            settingsPart.Enabled = settings.IsEnabled;

            // invalidates the cache
            _signals.Trigger("RedirectSettings");
        }
        public HttpResponseMessage SaveConfig(RedirectSettings settings)
        {
            try
            {
                _keyValueService.SetValue("redirectSettings_" + _key, JsonConvert.SerializeObject(settings));

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
        private RedirectSettings CreateEmptySettings()
        {
            RedirectSettings settings = new RedirectSettings();

            RedirectSetting createSettings = new RedirectSetting("createAllowed");

            RedirectSetting deleteSettings = new RedirectSetting("deleteAllowed");

            settings.Create = createSettings;

            settings.Delete = deleteSettings;

            return(settings);
        }
Пример #4
0
        private async Task postRequest(string token)
        {
            // parameters to send into post request
            // a list of providers
            List <string> provider = new List <string>();
            string        v1       = "no_bankid_netcentric";
            string        v2       = "no_bankid_mobile";

            provider.Add(v1);
            provider.Add(v2);

            // a list of include
            List <string> include = new List <string>();
            string        n1      = "name";
            string        n2      = "date_of_birth";

            include.Add(n1);
            include.Add(n2);

            // redirectsettings urls
            var redirectSettings = new RedirectSettings(
                successUrl: "https://developer.signicat.io/landing-pages/identification-success.html",
                abortUrl: "https://developer.signicat.io/landing-pages/something-wrong.html",
                errorUrl: "https://developer.signicat.io/landing-pages/something-wrong.html"
                );

            // the complete jsonbody
            var json = new BodyInfo(
                flow: "redirect",
                allowedProviders: provider,
                include: include,
                redirectSettings: redirectSettings
                );

            // sets the token as authorization header sets mediatype
            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));//ACCEPT header

            // converts the jsonBody into a string
            var jsonString = JsonConvert.SerializeObject(json);

            // Converts the string into a httpcontent
            content = new StringContent(jsonString, Encoding.UTF8, "application/json");

            try
            {
                // sends a post request to the api with a content
                var response = await client.PostAsync("https://api.idfy.io/identification/v2/sessions", content);

                // filters out the url of the response
                var sessionInfo = await response.Content.ReadAsAsync <SessionInfo>();

                string url = sessionInfo.url;
                sessionId = sessionInfo.id;

                // redirects to the bankidlogin
                //NavManager.NavigateTo(url);
                await JSRuntime.InvokeAsync <object>("open", url, "_blank");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }