Friday, April 27, 2012

Count Login Atempts



CountLoginAtempts()
                        label_failed_authentication.Text = "The username or password you entered is incorrect or not found."
                        label_failed_authentication.Visible = True



Private Sub CountLoginAtempts()
        Dim result As Object
        Dim count As Integer
        count = 1
        Dim cmm = New SqlCommand("select account_bad_attempts from users where email='" & text_Username.Text & "'")
        result = DataConnect.GetInstance.ExecuteScalar(cmm)
        If result IsNot Nothing Then
            count = count + Convert.ToInt64(result)
            If count < 5 Then
                cmm = New SqlCommand("Update users set account_bad_attempts=@count where email='" & text_Username.Text & "'")
            Else
                cmm = New SqlCommand("Update users set account_bad_attempts=@count,account_locked_yn=1 where email='" & text_Username.Text & "'")
            End If
            cmm.Parameters.Add("@count", SqlDbType.BigInt, 0).Value = count
            DataConnect.GetInstance.ExecuteNonQuery(cmm)
        End If
    End Sub

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...