两套系统采用独立的用户系统,都可以分开注册用户.
只是PetShop注册用户的时候,增加一个选项[用BBS用户登陆], 假如选择这个选项
那么在PetShop的Membership系统里面复制一份BBS的用户密码,并写入BBS的Cookie
这样整合的话,现在考虑用Discuz!NT里面的通行证,
然后下载Discuz!NT的Tookit http://nt.discuz.net/showtopic-81187.html
在keyDiscuzSessionHelper类把API,Secret,URL等变量值改成刚才操作步骤后的值
然后在PetShop的注册页面,加上如下代码:
DiscuzSession ds = DiscuzSessionHelper.GetSession();
try
{
User objUser = ds.GetUserInfo(ds.GetUserID(Login.UserName));
if (ds.EncodePassword(objUser.Password,true) == ds.EncodePassword(Login.Password, false))
{
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "ok", "alert('ok');", true);
//UID,Passwrod,MD5密码?(MD5=true/明文=false),cookie过期时间(分钟),Cookie domain
ds.Login(ds.GetUserID(Login.UserName), Login.Password, false, 100, "");
//Response.Redirect("SessionCreater.aspx?next=default");
Membership.CreateUser(Login.UserName, Login.Password);
}
else
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "fail", "alert('fail');", true);
}
catch (Exception ex)
{
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "exception", "alert('"+ ex.Message +"');", true);
}
try
{
User objUser = ds.GetUserInfo(ds.GetUserID(Login.UserName));
if (ds.EncodePassword(objUser.Password,true) == ds.EncodePassword(Login.Password, false))
{
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "ok", "alert('ok');", true);
//UID,Passwrod,MD5密码?(MD5=true/明文=false),cookie过期时间(分钟),Cookie domain
ds.Login(ds.GetUserID(Login.UserName), Login.Password, false, 100, "");
//Response.Redirect("SessionCreater.aspx?next=default");
Membership.CreateUser(Login.UserName, Login.Password);
}
else
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "fail", "alert('fail');", true);
}
catch (Exception ex)
{
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "exception", "alert('"+ ex.Message +"');", true);
}