Public Class ResetPassword1
    Inherits System.Web.UI.Page
    Private _account As Logic.DriverAccount

    Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        Try

            Dim code = Logic.Conversion.ToString(Request.Params("code"))
            Dim reset = New Logic.PasswordReset(code)
            _account = New Logic.DriverAccount(reset.accountId)

        Catch ex As ArgumentOutOfRangeException
            Response.Redirect("ForgotPassword.aspx")
        Catch ex As Exception
            Dim errorId = Logic.Error.Log(ex)
            Response.Redirect("/Error.aspx?id=" & errorId)
        End Try
    End Sub

    Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
        Response.Redirect("Default.aspx")
    End Sub

    Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click, btnDefault.Click
        If Not Page.IsValid Then
            Exit Sub
        End If

        Try
            _account.ChangePassword(txtPassword.Text)
        Catch ex As Exception
            Dim errorId = Logic.Error.Log(ex)
            Response.Redirect("/Error.aspx?id=" & errorId)
        End Try

        ' success
        Response.Redirect("ResetPassword_Success.aspx")

    End Sub

End Class