Exemple #1
0
        public ActionResult Login(UserInfo user)
        {
            user.UserName = Request.Form["username"];
            user.UserPass = Request.Form["password"];
            JavaDLL dll = new JavaDLL();

            user = dll.Login(Request.Form["username"]);
            if (user == null || !user.Valid)
            {
                ViewData["LoginMsg"] = "用户不存在";
                return(View(user));
            }
            if (user.Role == UserInfo.ROLE_CONF)
            {
                ViewData["LoginMsg"] = "账户已被限制使用";
                return(View(user));
            }
            string s = FormsAuthentication.HashPasswordForStoringInConfigFile(Security.MD5Encrypt(Request.Form["password"]), "MD5");

            if (s.Equals(user.UserPass))
            {
                Session["LoginUser"] = user;
                return(RedirectToAction(UserAuth.resultAction, UserAuth.recontroller));
            }
            else
            {
                ViewData["username"] = Request.Form["username"];
                ViewData["LoginMsg"] = "密码错误";
                return(View(user));
            }
        }
Exemple #2
0
        public string Login(string name, string sid, bool auto)
        {
            string   pasd = auto ? sid : FormsAuthentication.HashPasswordForStoringInConfigFile(Security.MD5Encrypt(sid), "MD5");
            JavaDLL  bll  = new JavaDLL();
            UserInfo info = bll.Login(name);

            if (info != null)
            {
                if (info.UserPass.Equals(pasd))
                {
                    var json = new
                    {
                        user   = info.UserName,
                        name   = info.NickName,
                        sid    = info.UserPass,
                        gender = info.Gender,
                        email  = info.Email,
                        mark   = info.Mark
                    };
                    JObject keyjson = JObject.FromObject(json);
                    string  date    = DateTime.Now.ToString("yyyyMMdd");
                    Log.e("Login:"******"logPath"] + "\\" + date + "\\user_" + date + ".log");
                    return(keyjson.ToString());
                }
                else
                {
                    return("true");
                }
            }
            else
            {
                return("false");
            }
        }
Exemple #3
0
        public void getUser(int id)
        {
            JavaDLL  bll   = new JavaDLL();
            UserInfo info  = Session["LoginUser"] as UserInfo;
            UserInfo Users = bll.Login(id);

            Session["TmpUser"] = Users;
            if (Users != null)
            {
                txtUserName.Text        = Users.UserName;
                txtNickName.Text        = Users.NickName;
                labEmail.Text           = Users.Email;
                txtRemark.Text          = Users.Mark;
                ddlGender.SelectedValue = "" + Users.Gender;
                ddlRole.SelectedValue   = "" + Users.Role;
                chkValid.Checked        = Users.Valid;
                if (Users.UserName.Equals("admin") || info.UserName.Equals(Users.UserName))
                {
                    txtUserName.Enabled          =
                        ddlRole.Enabled          =
                            linPassword.Visible  =
                                chkValid.Enabled = false;
                }
            }
        }
Exemple #4
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUser.Text.Trim().Length <= 0)
            {
                litError.Text = "请输入账号(账号为用户名或邮箱)";
                txtUser.Focus();
                return;
            }
            if (txtPwd.Text.Trim().Length <= 0)
            {
                litError.Text = "请输入密码";
                txtPwd.Focus();
                return;
            }
            JavaDLL  dll  = new JavaDLL();
            UserInfo info = dll.Login(txtUser.Text.Trim());

            if (info == null)
            {
                litError.Text = "用户不存在";
                return;
            }
            if (info.Role == UserInfo.ROLE_CONF)
            {
                litError.Text = "账户已被限制使用";
                return;
            }
            if (!info.Valid)
            {
                litError.Text = "无效的用户";
                return;
            }
            string s = FormsAuthentication.HashPasswordForStoringInConfigFile(Security.MD5Encrypt(txtPwd.Text), "MD5");

            if (s.Equals(info.UserPass))
            {
                Session["LoginUser"] = info;
                if (Request.QueryString["url"] != null && Request.QueryString["url"].Length > 0)
                {
                    Response.Redirect(Request.QueryString["url"]);
                }
                else
                {
                    Response.Redirect("HomePage.aspx");
                }
            }
            else
            {
                litError.Text = "密码输入不正确";
                txtPwd.Text   = string.Empty;
                txtPwd.Focus();
            }
        }
Exemple #5
0
        public string CreateKey(string key, string version, string max, string mark, string password)
        {
            JavaDLL dll = new JavaDLL();

            if (dll.Login("admin").UserPass.Equals(password))
            {
                return(dll.addKeys(key, Convert.ToInt32(max), version, mark).ToString());
            }
            else
            {
                return("Password error");
            }
        }
Exemple #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         bool state = false;
         if (Request.QueryString["id"] != null)
         {
             JavaDLL bll = new JavaDLL();
             if (Session["LoginUser"] == null)
             {
                 if (Request.QueryString["uid"] != null && Request.QueryString["sid"] != null)
                 {
                     UserInfo info = bll.Login(Request.QueryString["uid"]);
                     if (!info.UserPass.Equals(Request.QueryString["sid"]))
                     {
                         labError.Text = "你需要登录后才能发表";
                     }
                     else
                     {
                         Session["LoginUser"] = info;
                         imgPhone.Visible     = state = true;
                     }
                 }
                 else
                 {
                     labError.Text = "你需要登录后才能发表";
                 }
             }
             else
             {
                 state = true;
             }
             if (getData(bll, Convert.ToInt32(Request.QueryString["id"])) && state)
             {
                 btnComment.Enabled = true;
             }
         }
         else
         {
             Response.End();
         }
     }
 }
Exemple #7
0
        public ActionResult Details(string id)
        {
            JavaDLL  dll  = new JavaDLL();
            UserInfo info = dll.Login(id);

            if (info != null && info.Valid)
            {
                info.RoleStr = getRoles(info.Role);
                if (string.IsNullOrEmpty(info.HeadImg))
                {
                    info.HeadImg = "/images/head.jpg";
                }
                return(View(info));
            }
            else
            {
                return(RedirectToAction("Home", "Java21"));
            }
        }
Exemple #8
0
 protected void btnAmend_Click(object sender, EventArgs e)
 {
     if (txtName.Text.Trim().Length > 0)
     {
         UserInfo info = (UserInfo)Session["LoginUser"];
         info.NickName = txtName.Text.Trim();
         info.Mark     = txtRemark.Text;
         info.Gender   = Convert.ToInt32(ddlGender.SelectedValue);
         JavaDLL bll = new JavaDLL();
         if (bll.updateUser(info))
         {
             RunScript("alert('修改成功!');document.location.href='HomePage.aspx';");
         }
         else
         {
             RunScript("alert('修改失败!');");
         }
         Session["LoginUser"] = bll.Login(info.ID);
     }
     else
     {
         RunScript("alert('请输入昵称');");
     }
 }