A credential is information used to authenticate an identity. For tutor sign-in, the credentials are a username and password entered in an HTML form. Database access has a separate set of credentials: a Postgres user and password that let the application connect to its database. section 9.1 section 4.2.2
Credentials move through the tutor application in two stages:
- Registration collects a username and password. Browser-side checks handle required fields and field lengths; the submission handler checks whether the username already exists and whether the password matches its confirmation. section 8.2 section 8.3
- The frontend stores the registered user in a local Postgres database. Passwords should be stored as hashes rather than clear text; the implementation uses the argon2 crate. section 8.3 section 8.2
- At sign-in, an HTML form performs basic validation before sending a POST request. The route handler retrieves the user's credentials from the local database and verifies the submitted username and password. Failure redisplays the form with an error; success directs the user to the home page. section 9.1
#[derive(Serialize, Deserialize, Debug, sqlx::FromRow)]
pub struct User {
pub username: String,
pub tutor_id: i32,
pub user_password: String,
}
The Rust User model has username, tutor_id, and user_password fields; the corresponding database table holds the registered user's record. section 8.3
Keep the two credential roles distinct when configuring the application. A Postgres user is created, granted database privileges, and tested with psql; a DATABASE_URL then supplies connection details to sqlx. Those connection credentials are not the tutor's sign-in credentials. section 4.2.2 section 9.1
In this design, the frontend owns user authentication and session management, while the backend web service handles tutor and course data. The service is intended to receive requests from the trusted frontend rather than directly from users. section 8.2






