Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (SettingsOAuth.GoogleActive || SettingsOAuth.YandexActive || SettingsOAuth.TwitterActive ||
         SettingsOAuth.VkontakteActive || SettingsOAuth.FacebookActive || SettingsOAuth.MailActive)
     {
         var rootUrlPath    = Request.Url.AbsoluteUri.Contains("localhost") ? "~/" : SettingsMain.SiteUrl;
         var strRedirectUrl = PageToRedirect.IsNotEmpty() ? rootUrlPath + "/" + PageToRedirect : rootUrlPath;
         if (!string.IsNullOrEmpty(Request["code"]) && Request["auth"] == "vk")
         {
             VkontakteOauth.VkontakteAuth(Request["code"], strRedirectUrl, string.Empty);
             Response.Redirect(strRedirectUrl, false);
         }
         else if (!string.IsNullOrEmpty(Request["oauth_token"]))
         {
             TwitterOAuth.TwitterGetUser(Request["oauth_token"], string.Empty);
             Response.Redirect(strRedirectUrl, false);
         }
         else if (!string.IsNullOrEmpty(Request["code"]))
         {
             FacebookOauth.SendFacebookRequest(Request["code"], SettingsMain.SiteUrl + "/" + PageToRedirect);
             Response.Redirect(strRedirectUrl, false);
         }
         else if (OAuthResponce.OAuthUser(Request))
         {
             Response.Redirect(strRedirectUrl, false);
         }
     }
     else
     {
         divSocial.Visible = false;
     }
 }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!(SettingsOAuth.GoogleActive || SettingsOAuth.YandexActive || SettingsOAuth.TwitterActive ||
                  SettingsOAuth.VkontakteActive || SettingsOAuth.FacebookActive || SettingsOAuth.MailActive ||
                  SettingsOAuth.OdnoklassnikiActive))
            {
                Visible = false;
                return;
            }

            var rootUrlPath    = Request.Url.AbsoluteUri.Contains("localhost") ? "~/" : StringHelper.MakeASCIIUrl(SettingsMain.SiteUrl);
            var strRedirectUrl = PageToRedirect.IsNotEmpty() ? rootUrlPath + "/" + PageToRedirect : rootUrlPath;

            if (SettingsOAuth.VkontakteActive && !string.IsNullOrEmpty(Request["code"]) && string.Equals(Request["auth"], "vk"))
            {
                VkontakteOauth.VkontakteAuth(Request["code"], string.Empty, PageToRedirect);
                Response.Redirect(strRedirectUrl, false);
            }

            if (SettingsOAuth.OdnoklassnikiActive && !string.IsNullOrEmpty(Request["code"]) && string.Equals(Request["auth"], "od"))
            {
                OdnoklassnikiOauth.OdnoklassnikiLogin(Request["code"]);
                Response.Redirect(strRedirectUrl, false);
            }

            if (SettingsOAuth.GoogleActive && !string.IsNullOrEmpty(Request["code"]) && string.Equals(Request["auth"], "google"))
            {
                GoogleOauth.ExchangeCodeForAccessToken(Request["code"]);
                Response.Redirect(strRedirectUrl, false);
            }

            if (SettingsOAuth.FacebookActive && !string.IsNullOrEmpty(Request["code"]))
            {
                FacebookOauth.SendFacebookRequest(Request["code"], SettingsMain.SiteUrl + "/" + PageToRedirect);
                Response.Redirect(strRedirectUrl, false);
            }

            if ((SettingsOAuth.GoogleActive || SettingsOAuth.YandexActive || SettingsOAuth.MailActive) &&
                OAuthResponce.OAuthUser(Request))
            {
                Response.Redirect(strRedirectUrl, false);
            }
        }