2014年7月13日 星期日

[RESOLVED] login problem


hi i have this code to do some action if button clicked for 3 times. Just like if users enters a wrong password for 3 times the account is blocked


this the code where LoginAttempt is set default value to 0


if(user.LoginAttempt < 3){

if(!login)
{
user.LoginAttempt = user.LoginAttempt + 1;
}
else
{
user.LoginAttempt = 0;
}
}
else
{
//do something
}

here is my login code how to make work with the first code


 var result = _datamoel.Users.FirstOrDefault(i => i.UserName.Equals(txtuser.Text) && i.Password.Equals(txtpass.Text));
if (result != null)
{

result.UserTypeReference.Load();
Session["Username"] = txtuser.Text;
if (result.UserType.TypeName.Equals("clerk"))
Response.Redirect("clerk/clerkPage.aspx");

}

else

lblmsgw.Text = "UserName/Passsword Not Correct! Please Change UserName/Passsword and Try again";



If you are using Asp.NET Membership provider you can configure the provider to have login attempts,

maxInvalidPasswordAttempts="3"
{any attempt number}.For more see
Login Attempts


You can store the number of attempts in a Session variable say Session["Attempts"]. if the value exceeds 3 then show an error message.


沒有留言:

張貼留言