protected void ManagePosts(object sender, EventArgs e)
 {
     if (isCorrectUserLog(LoginAccessMyPosts.Value.Trim(), PassAccessMyPosts.Text.Trim()) == true)
     {
         AppUser Usr = new AppUser(LoginAccessMyPosts.Value.Trim(), PassAccessMyPosts.Text.Trim(), AppUser.GetUserId(LoginAccessMyPosts.Value.Trim(), PassAccessMyPosts.Text.Trim()));
         Session["User"]= Usr;
         Response.Redirect("MyPosts.aspx");
     }
 }
示例#2
0
        public static AppUser GetUser(string Log, string Pass)
        {
            try
            {
                string query = @"
                                BEGIN
                                SELECT [ID]
                                      ,[Login]
                                      ,[Password]
                                      ,[IsValid]
                                      ,[Firstname]
                                      ,[Name]
                                  FROM [dbo].[Users]
                                  WHERE
                                  Login like @Mail COLLATE French_BIN
                                  and Login is not null and Login <>''
                                  and Password like @Pass COLLATE French_BIN
                                  and Password is not null and Password <>''
                                END
                            ";

                SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["db_SE"].ConnectionString);
                SqlCommand command = new SqlCommand(query, connection);
                SqlDataAdapter adapter = new SqlDataAdapter(command);

                command.CommandTimeout = 0;
                DataSet result = new DataSet();
                result.Locale = CultureInfo.InvariantCulture;

                command.Parameters.AddWithValue("@Mail", Log.Trim());
                command.Parameters.AddWithValue("@Pass", Pass.Trim());

                adapter.Fill(result);

                if (result != null && result.Tables.Count > 0 && result.Tables[0].Rows.Count > 0)
                {

                    AppUser Usr = new AppUser(Log.Trim(), Pass.Trim(), Convert.ToInt32(result.Tables[0].Rows[0]["ID"]));
                    return Usr;
                }

                return null;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] != null)
            {
                Usr = (AppUser)Session["User"];

                if (Login.Value == "")
                {
                    Pass.Attributes.Add("value", "ThePassword");
                }
                else
                {
                    Pass.Attributes.Add("value", "");
                }

                ActivatedSession = 1;
                Login.Value = Usr.Login;
            }
            else
            {
                ActivatedSession = 0;
            }

            string _Login = Request.Params["Lgn"];
            string _Pass = Request.Params["Ps"];

            if (_Login != null && _Pass != "")
            {
                if (AppUser.ValidateUser(_Login, _Pass))
                {
                    PnlGoodPost.Visible = false;
                    PnlBadAfterConf.Visible = false;
                    PnlValidMail.Visible = true;
                    PnlAddPost.Visible = false;
                }
            }

            if (!Page.IsPostBack)
            {
                Category.LoadCategoriesGen(ddlbCat);
                Category.LoadCategoriesGen(ddlbCat1);
            }
        }