Inheritance: OAuthClientBase
コード例 #1
0
 public HttpResponseMessage Reply(int id, string mode, bool keep)
 {
     OAuthClient = new FacebookClient(id, ToMode(mode)) { CallbackUri = CallbackUri("Facebook", id, mode, keep) };
     bool shouldAuthorize = OAuthClient.IsCurrentService() && OAuthClient.HaveVerificationCode();
     KeepLoggedIn = keep;
     if (ToMode(mode) == AuthMode.Login)
     {
         shouldAuthorize = shouldAuthorize || OAuthClient.IsCurrentUserAuthorized();
     }
     if (shouldAuthorize)
     {
         if (OAuthClient.Authorize() == AuthorisationResult.Authorized)
         {
             OAuthClient.AuthenticateUser(OAuthClient.GetCurrentUser<FacebookUserData>(), PortalSettings, GetIpAddress(), AddCustomProperties, OnUserAuthenticated);
             if (AuthResult.User == null && (ToMode(mode) == AuthMode.Register | mode.ToLower() == "mixed"))
             {
                 var newUser = RegisterUser();
                 OAuthClient.AuthenticateUser(OAuthClient.GetCurrentUser<FacebookUserData>(), PortalSettings, GetIpAddress(), AddCustomProperties, OnUserAuthenticated);
             }
         }
     }
     // redirect
     string returnurl = HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies["returnurl"].Value);
     HttpContext.Current.Response.Redirect(returnurl);
     return Request.CreateResponse(HttpStatusCode.OK);
 }
コード例 #2
0
 public HttpResponseMessage Call(int id, string mode, string returnurl, bool keep)
 {
     SetReturnUrlCookie(returnurl);
     OAuthClient = new FacebookClient(id, ToMode(mode)) { CallbackUri = CallbackUri("Facebook", id, mode, keep) };
     AuthorisationResult result = OAuthClient.Authorize();
     if (result == AuthorisationResult.Denied)
     {
         return Request.CreateResponse(HttpStatusCode.ServiceUnavailable,
             Localization.GetString("PrivateConfirmationMessage"));
     }
     return Request.CreateResponse(HttpStatusCode.OK);
 }