Example #1
0
 //验证当前的AuthToken是否可用
 public bool ValidateAuthToken(DiscuzSession ds, ref int Errorcode)
 {
     try
     {
         ds.session_info = ds.GetSessionFromToken(new HttpContextSession("AuthToken").GetSession().ToString());
         Errorcode = 0;
         return true;
     }
     catch (DiscuzException d)
     {
         Errorcode = d.ErrorCode;
         return false;
     }
     catch (NullReferenceException)
     {
         Errorcode = 0;
         return false;
     }
 }
Example #2
0
 private void VerfyUser()
 {
     DiscuzSession ds = new DiscuzSession(api, secret, url);
     try
     {
         ds.GetSessionFromToken(Request.QueryString["auth_token"]);
     }
     catch (DiscuzException de)
     {
         if (de.ErrorCode == 102)
         {
             Uri uri = ds.CreateToken();
             Response.Redirect(uri.ToString());
         }
         else
         {
             throw de;
         }
     }
     User user = ds.GetUserInfo(ds.GetLoggedInUser().UId);
     if (user.GroupId != 1)//不是管理员
     {
         Response.Redirect("UrlConfig.aspx");
     }
 }
Example #3
0
 //验证当前的AuthToken是否可用
 public bool ValidateAuthToken(DiscuzSession ds, ref int Errorcode)
 {
     try
     {
         if (Request.Cookies["dnt"] != null)
         {
             ds.session_info = ds.GetSessionFromToken(Session["AuthToken"].ToString());
         }
         else
         {
             needlogin = true;
         }
         Errorcode = 0;
         return true;
     }
     catch (DiscuzException d)
     {
         Errorcode = d.ErrorCode;
         return false;
     }
     catch (NullReferenceException)
     {
         Errorcode = 0;
         return false;
     }
 }