At the school district where I work, we have a unique system in place that allows parents to access district and class resources. This system involves using a third-party product, which unfortunately has caused some issues. When a parent logs in, they are actually logging into a site that I personally created. To determine if they are authorized to proceed to the third-party site, I conduct checks on their account. If they are authorized, I automate a form submission with the necessary login details for the parent.
One challenge I face is that our vendor does not consistently update new data. Thus, when a student is newly enrolled at one of our schools, the parent may successfully log in and authorize on my platform. However, upon redirection to the third-party site, they encounter an error message indicating no associated students. Regrettably, I am unable to directly contact the vendor to resolve this issue.
To tackle this problem, I aim to run the form submission to the third party in a "testing" mode. This way, I can capture the resulting page in a buffer and check for any error messages. If an error message is detected, I will retain them on my platform and provide basic resources. Conversely, if no error message is found, the actual form submission will take place, allowing the browser to redirect accordingly. Perhaps utilizing an AJAX solution would be beneficial for this task. Below is the existing code snippet:
ASPX page (with relevant code):
<form method="post" name="loginform" action="http://[destination page]" target="_top">
<input type="hidden" name="username" value="<% =SessionHandler.UserEmail %>" />
<input type="hidden" name="password" value="<% =SessionHandler.UserPassword %>" />
</form>
Javascript function (to execute the form submit):
function parentFormSubmit() {
document.loginform.submit();
}
VB Codebehind snippet:
Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadComplete
Session.Abandon()
FormsAuthentication.SignOut()
Page.ClientScript.RegisterStartupScript(Me.[GetType](), "alert", "parentFormSubmit();", True)
End Sub