Skip to content

Instantly share code, notes, and snippets.

@ckimrie
Created July 17, 2017 16:23
Show Gist options
  • Save ckimrie/b72b83573aee5228ad9a5d3e9026a8b8 to your computer and use it in GitHub Desktop.
Save ckimrie/b72b83573aee5228ad9a5d3e9026a8b8 to your computer and use it in GitHub Desktop.
Reference user profile entity and objects.
interface User {
//Identification & Classification
userId: number;
userName: string; //Unique key for application
type: "MEMBER" | "GUEST" | "ANONYMOUS";
application: Application; //eg User is a member of the Chiltern Arriva system ('application' provides flexibility
// for Chiltern to have many apps with Ace system)
//Profile
firstName: string;
lastName: string;
dateOfBirth: string //ISO 8601 Date only
//Profile entities
emails: UserEmail[];
addresses: UserAddress[];
telephones: UserTelephone[];
cards: UserCard[];
devices: UserDevice[];
preferences: UserPreference[];
data: UserData[]; // to allow for arbitrary key:value data storage if needed in future. Enforces `key` being unique
history: UserData[]; //For things like recent stations etc. Allows multiple `key` values. Limited to ~20 items?
//Authentication
password: string;
passwordSalt: string;
attachedLogins: UserThirdPartyLogin[]; //For social Cognito logins. Its probably better to _only_ store token in
// clients, but unsure of exact limitations, so would rather have this here
// just in case and not use
//Account status control
isApproved: boolean;
isLockedOut: boolean;
isDisabled: boolean;
//Login flow control
requireNewPasswordAtLogin: boolean;
failedPasswordAttemptCount: number;
//Password reset
passwordResetToken: string;
passwordResetTokenIssuedAt: Date;
//Auditing
createdAt: Date;
updatedAt: Date;
approvedAt: Date;
lastActivityAt: Date;
lastLockoutAt: Date;
lastPasswordChangeAt: Date;
lastLoginAt: Date;
//Extras
userMessages: UserMessage[]; //To show user persistent messages in UI (eg within My Account)
comment: string; //For internal use
}
interface UserEmail {
emailId: number;
primary: boolean;
label: string;
email: string; //Forced to lower case
verified: boolean;
verifiedToken: string;
verifiedTokenIssuedAt: Date;
createdAt: Date;
updatedAt: Date;
}
interface UserAddress {
addressId: number;
primary: boolean;
label: string;
addressLine1: string;
addressLine2: string;
addressLine3: string;
city: string;
postCode: string;
country: string;
createdAt: Date;
updatedAt: Date;
}
interface UserTelephone {
telephoneId: number;
telephoneNumber: string;
primary: boolean;
createdAt: Date;
updatedAt: Date;
}
interface UserThirdPartyLogin {
loginId: number;
login: string;
token: string;
expiresAt: Date;
createdAt: Date;
updatedAt: Date;
}
interface UserDevice {
deviceId: number;
label: string;
deviceName: string;
hardwareType: string; //iPhone 4S, Galaxy S5 etc
primary: true;
lastActivityAt: Date;
createdAt: Date;
updatedAt: Date;
}
interface UserCard {
cardId: number;
label: string;
cardType: "VISA" | "MASTERCARD" | "AMEX" | "OTHER";
cardName: string;
cardNumber: string; //This is obfuscated to the format XXXX-XXXX-XXXX-7668
cardExpiry: string; //Eg "01/18"
token: string;
tokenIssuer: string;
expiresAt: Date;
createdAt: Date;
updatedAt: Date;
}
interface UserPreference {
preferenceId: number;
category: string; //eg SEAT
code: string; //eg DIRECTION, Used for grouping items in the UI
codelabel: string; //eg Seat Direction
value: string; //eg BACKWARD
valueLabel: string; //eg Backwards
createdAt: Date;
updatedAt: Date;
}
interface UserData {
dataId: number;
key: string;
value: string;
createdAt: Date;
updatedAt: Date;
}
interface UserMessage {
messageId: number;
message: string;
type: "INFO" | "ALERT" | "ERROR" | "DATA";
dismissed: boolean;
dismissable: boolean;
dismissedAt: Date;
expiresAt: Date;
createdAt: Date;
updatedAt: Date;
}
interface UserHistory {
historyId:string;
key:string;
value:string;
createdAt: Date;
updatedAt: Date;
}
interface Application {
applicationId: number;
name: string;
ownerToc: Client;
createdAt: Date;
updatedAt: Date;
}
interface Client {
clientId: number;
name: string;
createdAt: Date;
updatedAt: Date;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment