Getting profile details with OAuth
The starting point is to extend the data model so that it is possible to associate customers in the database with their Google accounts. When the OAuth service provides the SportsStore application with user data, a unique ID is included, which will be stored in the database alongside the customer’s name and email, and used to query the customer’s address if one is available in the SportsStore database. Listing 19.3 adds a new property to the Customer
interface.
Listing 19.3: Adding a property to the customer_models.ts file in the src/data folder
export interface Customer {
id?: number;
name: string;
email: string;
federatedId?: string;
}
The new property requires a validation rule, as shown in Listing 19.4.
Listing 19.4: Adding a new property to the order_rules.ts file in the src/data/validation folder
import { Validator } from "./validator";
import { required, minLength, email, no_op...