指定された試行が失敗した後、ユーザーをブロックする方法を教えてください。30 分後、またはいつでも、ユーザーは再度ログインできるようになります。ログイン用のサンプル コードを次に示します。
public partial class Login : System.Web.UI.Page
{
SimplerAES AES = new SimplerAES();
protected void Page_Load(object sender, EventArgs e)
{
Session.Clear();
}
protected void btnLogIn_Click(object sender, EventArgs e)
{
if (txtUsername.Text == "" || txtPassword.Text == "")
{
lblMessage.Visible = true;
txtUsername.Text = "";
txtPassword.Text = "";
lblMessage.Text = "Invalid Username/Password";
}
else
{
SqlConnection con = new SqlConnection(SeiboLMS.Helper.GetConnectionString());
con.Open();
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandType = CommandType.Text;
com.CommandText = "SELECT * FROM Users WHERE UserName=@UserName";
com.Parameters.Add("@UserName", SqlDbType.NVarChar);
com.Parameters[0].Value = txtUsername.Text;
SqlDataReader data = com.ExecuteReader();
if (data != null)
{
while (data.Read())
{
if (txtPassword.Text == AES.Decrypt(data["Password"].ToString()))
{
if (data["UserTypeID"].ToString() == "1")
{
Session["userid"] = data["UserID"].ToString();
Session["usertypeid"] = data["UserTypeID"].ToString();
Session["username"] = data["UserName"].ToString();
Session["password"] = data["Password"].ToString();
Helper.Logs(int.Parse(data["UserID"].ToString()), 1, "Log In Successful");
Response.Redirect("Admin/Default.aspx");
}
else
{
Session["userid"] = data["UserID"].ToString();
Session["usertypeid"] = data["UserTypeID"].ToString();
Session["username"] = data["UserName"].ToString();
Session["password"] = data["Password"].ToString();
Helper.Logs(int.Parse(data["UserID"].ToString()), 1, "Log In Successful");
Response.Redirect("Employees/Default.aspx");
}
}
else
{
lblMessage.Text = "Invalid Username/Password.";
txtUsername.Text = "";
txtPassword.Text = "";
}
}
}
else
{
lblMessage.Text = "Invalid Username/Password.";
txtUsername.Text = "";
txtPassword.Text = "";
}
data.Close();
con.Close();
con.Dispose();
}
}
}
そこにどんなアイデアがあるか教えてください。前もって感謝します..