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); } }
public async Task SignUpOauth(HttpRequest request, string id, string type) { var oauthRequestToken = request.Form["Token"]; GoogleOauth oauthInfo = await storageService.CallJSON <GoogleOauth>("https://oauth2.googleapis.com/tokeninfo?id_token=" + oauthRequestToken); //GETS EMAIL FOR GOOGLE OAUTH var password = encryptionService.EncryptPassword("!!0_STREAMWORK_!!0"); var profile = new Profile { Id = id, Name = oauthInfo.Name.Contains(' ') ? oauthInfo.Name.Replace(' ', '|') : oauthInfo.Name + "|", EmailAddress = oauthInfo.Email, Username = Request.Form["Username"], Password = password, ProfileType = type, College = Request.Form["SchoolName"], NotificationSubscribe = "True", Expiration = DateTime.UtcNow, AcceptedTutor = false, LastLogin = DateTime.UtcNow, ProfileColor = MiscHelperMethods.GetRandomColor(), ProfileSince = DateTime.UtcNow, ProfilePicture = MiscHelperMethods.defaultProfilePicture, ProfileBanner = MiscHelperMethods.defaultBanner, TimeZone = MiscHelperMethods.GetTimeZoneBasedOfOffset(Request.Form["Time"]) }; if (type == "tutor") { profile.PayPalAddress = Request.Form["PayPalAddress"]; await AddUs5AsFollowers(id); } await storageService.Save(id, profile); await cookieService.SignIn(Request.Form["Username"], encryptionService.DecryptPassword(password, "!!0_STREAMWORK_!!0")); }
//protected void lnkbtnTwitterClick(object sender, EventArgs e) //{ // TwitterOAuth.TwitterOpenAuth(); //} protected void lnkbtnGoogleClick(object sender, EventArgs e) { GoogleOauth.SendAuthenticationRequest(); }