Page 1 of 1

Detect failed login attempts

Posted: Wed Apr 28, 2021 7:56 am
by MrBlack
Hello,

I am new to the forum, but read a lot through it, which helped me solve several problems already. Thanks!

I am trying to detect bad login attempts and found the InvalidUsernameOrPasswordException() class, but can't catch the exception. The idea would be to somehow disable the user after three failed attempts.

Thank you in advance for your help.

Code: Select all

void btnLogin_Click(System.Object sender, System.EventArgs e)
{
	try
	{
		Globals.Security.Login("User1", "2");		// 2 is not the password for User1
	}
	catch (InvalidUsernameOrPasswordException)
	{
		Globals.Tags.ExceptionHappened.SetTag();	// Tag not set altough login failed
	}
}