Exemplo n.º 1
0
    void InitProfile(HttpContext context)
    {
        try {
            string name = context.Server.UrlDecode(context.Request["name"]);
            string spid = context.Request["spid"];
            string rememberme = context.Request["remember"];
            RightService server = new RightService();
            UserDetail user = server.GetUserDetail(name);
            Employee obj = new Employee {
                Id=System.Guid.NewGuid(),
                Name = name ,
                SpecialtyId = spid ,
                Code = user.EmployeeCode ,
                Roles = { }
            };

            RepositoryFactory<Employees>.Get().Add(obj);
            SetAuthCookie(user.EmployeeCode , rememberme == "1" , context);
        }catch( Exception ex){
            context.Response.Write(ex.Message);
        }
    }
Exemplo n.º 2
0
 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);
     }
 }