示例#1
0
文件: Login.aspx.cs 项目: HuGuo/TSS
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string loginName = txtLoginName.Text.Trim();
        string loginPwd = txtPassword.Text;
        RightService server = new RightService();
        int result= server.Login(loginName , loginPwd.GetMD5());
        if (result == 0) {
            UserDetail user = server.GetUserCompleteDetail(loginName);
            //log
            AppLog.Write(string.Format("[login] {0} 登录成功" , loginName) , AppLog.LogMessageType.Info);
            bool existsCode = RepositoryFactory<Employees>.Get().ExistsCode(user.EmployeeCode);
            string redirectUrl = Request.QueryString["ReturnUrl"] ?? "default.htm";
            if (existsCode) {
                //授权 登录
                Helper.SetAuthCookie(user.EmployeeCode , false , HttpContext.Current);

                //log
                //AppLog.Write(string.Format("[login] {0} 登录成功" , loginName) , AppLog.LogMessageType.Info);

                Response.Redirect(redirectUrl , true);
            } else {
                //第一次登陆,跳转设置专业信息
                redirectUrl = string.Format("InitProfile.aspx?name={0}&uc={1}&ReturnUrl={2}" , Server.UrlEncode(loginName) , Server.UrlEncode(user.EmployeeCode) , Server.UrlEncode(redirectUrl));
                Response.Redirect(redirectUrl,true);
            }
        } else {
            ltmsg.Text = Helper.LoginResult[result];
        }
    }
示例#2
0
文件: LoginHandler.cs 项目: HuGuo/TSS
 void Validate(HttpContext context)
 {
     try {
         string name = context.Server.UrlDecode(context.Request["name"]);
         string pwd = context.Server.UrlDecode(context.Request["pwd"]);
         string remberme = context.Request["remember"];
         RightService server = new RightService();
         int result = server.Login(name , pwd.GetMD5());
         if (result==0) {
             UserDetail user = server.GetUserDetail(name);
             bool firstLogin = RepositoryFactory<Employees>.Get().ExistsCode(user.EmployeeCode);
             //第一次登录系统
             if (!firstLogin) {
                 result = 4;
             } else {
                 //
                 SetAuthCookie(user.EmployeeCode , remberme == "1" , context);
             }
         }
         context.Response.Write(Helper.LoginResult[result]);
     } catch (Exception ex){
         context.Response.Write(ex.Message);
     }
 }