You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
3.8 KiB
97 lines
3.8 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using System.Web.Security;
|
|
using System.Web.Script.Serialization;
|
|
using System.Text;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// SysUserHandler 的摘要说明
|
|
/// </summary>
|
|
public class SysUserHandler : IHttpHandler
|
|
{
|
|
string app = System.Configuration.ConfigurationManager.AppSettings["APP"];
|
|
private FangYar.BLL.TBL.SysUsersBLL bll = new BLL.TBL.SysUsersBLL();
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
|
|
context.Response.ContentType = "text/json";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
switch (action)
|
|
{
|
|
case "UserInfo2":
|
|
returnstr = GetUserInfo2(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
private string GetUserInfo2(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
FangYar.Model.LoginUserModel buser = new Model.LoginUserModel();
|
|
try
|
|
{
|
|
string UsersUid = context.Request.Params["UsersUid"];
|
|
buser = bll.GetLoginUserModelByUID(UsersUid);
|
|
if (buser != null)
|
|
{
|
|
if (buser.state == "0")
|
|
{
|
|
//获取用户角色
|
|
string rolesid = FangYar.BLL.CommomBLL.GetTableIDS("rules_id", "users_uid", "TBL_SYS_USERSRULES", " where users_uid='" + UsersUid + "' and app_id='" + app + "' and rules_type='2' ");
|
|
buser.roles = rolesid;
|
|
//获取用户权限
|
|
string rigths = FangYar.BLL.CommomBLL.GetTableIDS("PERM_VALUE", "app_id", "TBL_SYS_PERM", " where id in(select perm_id from TBL_SYS_ROLEPERM where ROLE_ID in('" + rolesid.Replace(",", "','") + "') and app_id='" + app + "' ) ");
|
|
buser.rights = rigths;
|
|
//获取用户区域
|
|
FangYar.Model.TBL.TBL_SYS_ORG_Model area = new BLL.TBL.SysOrgBLL().GetModelByID(buser.OrgID);
|
|
if (area != null) { buser.AreaID = area.AREA_ID; }
|
|
StringBuilder userdata = new StringBuilder();
|
|
new JavaScriptSerializer().Serialize(buser, userdata);
|
|
//数据放入ticket
|
|
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, UsersUid, DateTime.Now, DateTime.Now.AddMinutes(720), true, userdata.ToString());
|
|
//数据加密
|
|
string enyTicket = FormsAuthentication.Encrypt(ticket);
|
|
//将身份信息保存在cookie中,验证当前请求是否是有效请求
|
|
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, enyTicket);
|
|
HttpContext.Current.Response.Cookies.Add(cookie);
|
|
returnstr = "{\"code\":1,\"msg\":\"获取信息成功\",\"data\":" + FangYar.Common.JsonHelper.ToJson(buser) + "}";
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"您的账户已锁定!请联系管理员!\"}";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"无此用户信息\"}";
|
|
}
|
|
|
|
}
|
|
catch
|
|
{
|
|
returnstr = "{\"code\":-3,\"msg\":\"error\",\"data\":[]}";
|
|
}
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|