Database Schema Update

First, we must add a password field to our existing users table. We’ll use ALTER TABLE to add a password column (refer back to Module 2 Lesson 1 for the ALTER TABLE syntax). In Workbench, run this SQL command:

ALTER TABLE users ADD COLUMN password VARCHAR(255) NOT NULL;

Updated User Interfaces

We need to update our existing User interface and create a new UserResponse interface in interfaces.ts:

// Full user interface (for database operations)
export interface User {
  id: number;
  username: string;
  email: string;
  password?: string; // Needed for login password verification
}

// User response interface (for API responses - no password)
export interface UserResponse {
  id: number;
  username: string;
  email: string;
}

We need two interfaces because:

  • User includes the password field for internal database operations (like login verification).
  • UserResponse excludes the password for security - we never send password hashes to the front-end.

Use UserResponse for all API responses, not User.



Repo link

Tags: