public string ValidateUser(string mail, string pass)
    {
        JavaScriptSerializer j = new JavaScriptSerializer();
        UserT temp             = new UserT(mail, pass);

        return(j.Serialize(temp.CheckLogin()));
    }
Beispiel #2
0
    /// <summary>
    /// כפתור התחברות - בדיקת פרטי משתמש והפניה על פי הרשאה
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void login_BTN_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            if (Session["counter"] == null)
            {
                Session["counter"] = 0; //מונה לבדיקת מס' הפעמים שהמשתמש טעה - שליחה לדף איפוס אחרי 5 בדיקות
            }

            UserT temp = new UserT(mail_TB.Text, pass_TB.Text);
            //UserT temp = new UserT(mail_TB.Value, pass_TB.Text);
            if (temp.CheckLogin()) //בדיקה אם משתמש קיים ופרטים נכונים
            {
                // בדיקה האם המשתמש עם סיסמא זמנית. אם כן - נשלח אותו ליצירת סיסמא חדשה
                if (temp.Password == "000000")
                {
                    Server.Transfer("RestorePass.html");
                }
                int auth = temp.CheckAuthDesktop(); //בדיקה אם יש הרשאה לדף ניהול
                Session["UserID"] = temp.UserId;
                if (remember_CB.Checked && auth != -1)
                {
                    SaveCookies(auth, temp.UserId);
                }
                DirectTo(auth);
            }
            else
            {
                int counter = int.Parse(Session["counter"].ToString());
                counter++;
                if (counter >= 5)
                {
                    Session.Remove("counter");
                    Response.Redirect("forgotPass.html");
                    //שליחה לדף איפוס סיסמה
                }
                else
                {
                    Session["counter"] = counter;
                    Label lbl = new Label();
                    lbl.Font.Size = 14;
                    lbl.Text      = "אימייל או סיסמה שגויים";
                    serverMSG_PH.Controls.Add(lbl);
                }
            }
        }
    }