Пример #1
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);
            }
        }
Пример #2
0
 protected void lnkbtnOdnoklassnikiClick(object sender, EventArgs e)
 {
     OdnoklassnikiOauth.OdnoklassnikiAuthDialog();
 }