Class LoginPost

All Implemented Interfaces:
spark.Route

public class LoginPost extends PostRoute
The LoginPost class handles the POST request for processing the login form submission.
  • Field Details

    • logger

      private org.slf4j.Logger logger
      The logger for this class.
  • Constructor Details

    • LoginPost

      public LoginPost(App app)
      Constructs a LoginPost route with the specified application.
      Parameters:
      app - the application instance
  • Method Details

    • handlePost

      public void handlePost(spark.Request request, spark.Response response) throws SQLException
      Handles the POST request for the login form submission. This method checks the user's credentials and logs them in if they are valid. If the user's credentials are invalid, the user is redirected back to the login page with an error message. If the credentials are valid, the session is updated with the user's identifier and username attributes.
      Specified by:
      handlePost in class PostRoute
      Parameters:
      request - the HTTP request
      response - the HTTP response
      Throws:
      SQLException - if an SQL error occurs