2023-01-06 16:27:42 +00:00
|
|
|
//--- satellite console ---//
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// User contains information about people who have frontend access.
|
2023-01-06 16:27:42 +00:00
|
|
|
model user (
|
|
|
|
key id
|
|
|
|
|
2023-03-16 13:08:49 +00:00
|
|
|
index (
|
|
|
|
name users_email_status_index
|
|
|
|
fields normalized_email status
|
|
|
|
)
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// id is an uuid for the user.
|
2023-01-06 16:27:42 +00:00
|
|
|
field id blob
|
2023-02-08 12:56:50 +00:00
|
|
|
// email is the user specified email.
|
2023-01-06 16:27:42 +00:00
|
|
|
field email text ( updatable )
|
2023-02-08 12:56:50 +00:00
|
|
|
// normalized_email is the email transformed by usual rules, e.g. case-insensitive.
|
|
|
|
// See satellitedb.normalizeEmail for the specific details.
|
2023-01-06 16:27:42 +00:00
|
|
|
field normalized_email text ( updatable )
|
2023-02-08 12:56:50 +00:00
|
|
|
// full_name is the user specified name.
|
2023-01-06 16:27:42 +00:00
|
|
|
field full_name text ( updatable )
|
2023-02-08 12:56:50 +00:00
|
|
|
// short_name is the user specified name, that should be usually used for informal information.
|
2023-01-06 16:27:42 +00:00
|
|
|
field short_name text ( updatable, nullable )
|
2023-02-08 12:56:50 +00:00
|
|
|
// password_hash is the bcrypt hash.
|
2023-01-06 16:27:42 +00:00
|
|
|
field password_hash blob ( updatable )
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// status indicates whether the user is inactive=0, active=1, or deleted=2. See console.UserStatus for details.
|
2023-01-06 16:27:42 +00:00
|
|
|
field status int ( updatable, autoinsert )
|
2023-02-08 12:56:50 +00:00
|
|
|
// user_agent contains the partner parameter from registration.
|
2023-06-13 16:58:24 +01:00
|
|
|
field user_agent blob ( updatable, nullable )
|
2023-02-08 12:56:50 +00:00
|
|
|
// created_at indicates when the user was created.
|
2023-01-06 16:27:42 +00:00
|
|
|
field created_at timestamp ( autoinsert )
|
2023-02-08 12:56:50 +00:00
|
|
|
|
|
|
|
// project_limit limits how many projects a user can create.
|
2023-01-06 16:27:42 +00:00
|
|
|
field project_limit int ( updatable, default 0 )
|
2023-02-08 12:56:50 +00:00
|
|
|
// project_bandwidth_limit is project default maximum allowed bandwidth per month in bytes.
|
2023-01-06 16:27:42 +00:00
|
|
|
field project_bandwidth_limit int64 ( updatable, default 0 )
|
2023-02-08 12:56:50 +00:00
|
|
|
// project_storage_limit is project default maximum allowed bytes that can be stored.
|
2023-01-06 16:27:42 +00:00
|
|
|
field project_storage_limit int64 ( updatable, default 0 )
|
2023-02-08 12:56:50 +00:00
|
|
|
// segment_limit is project default on how many segments can be stored in the project.
|
2023-01-06 16:27:42 +00:00
|
|
|
field project_segment_limit int64 ( updatable, default 0 )
|
2023-02-08 12:56:50 +00:00
|
|
|
// paid_tier indicates whether user is paying for access.
|
2023-01-06 16:27:42 +00:00
|
|
|
field paid_tier bool ( updatable, default false )
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// position is user-specified position in a company.
|
2023-01-06 16:27:42 +00:00
|
|
|
field position text ( updatable, nullable )
|
2023-02-08 12:56:50 +00:00
|
|
|
// company_name is user-specified company name.
|
2023-01-06 16:27:42 +00:00
|
|
|
field company_name text ( updatable, nullable )
|
2023-02-08 12:56:50 +00:00
|
|
|
// company_size is user-specified company size estimate.
|
2023-01-06 16:27:42 +00:00
|
|
|
field company_size int ( updatable, nullable )
|
2023-02-08 12:56:50 +00:00
|
|
|
// working_on is user-specified info on what the user intends to use things for.
|
2023-01-06 16:27:42 +00:00
|
|
|
field working_on text ( updatable, nullable )
|
2023-02-08 12:56:50 +00:00
|
|
|
// is_professional indicates whether the user intends to use it for personal or business.
|
2023-01-06 16:27:42 +00:00
|
|
|
field is_professional bool ( updatable, default false )
|
2023-02-08 12:56:50 +00:00
|
|
|
// empolyee_count is user-specified estimate on the employee count in the company.
|
2023-01-06 16:27:42 +00:00
|
|
|
field employee_count text ( updatable, nullable )
|
2023-02-08 12:56:50 +00:00
|
|
|
// have_sales_contact indicates whether the user should be contacted by sales.
|
2023-01-06 16:27:42 +00:00
|
|
|
field have_sales_contact bool ( updatable, default false )
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// mfa_enabled indicates whether multi-factor authentication is enabled for this user.
|
2023-01-06 16:27:42 +00:00
|
|
|
field mfa_enabled bool ( updatable, default false )
|
2023-02-08 12:56:50 +00:00
|
|
|
// mfa_secret_key is the shared key between authenticator and the frontend.
|
2023-01-06 16:27:42 +00:00
|
|
|
field mfa_secret_key text ( updatable, nullable )
|
2023-02-08 12:56:50 +00:00
|
|
|
// mfa_recovery_codes is used for disabling multi-factor authentication.
|
2023-01-06 16:27:42 +00:00
|
|
|
field mfa_recovery_codes text ( updatable, nullable )
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// signup_promo_code is the promo code, if it was used when signing up.
|
2023-01-06 16:27:42 +00:00
|
|
|
field signup_promo_code text ( updatable, nullable )
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// verification_reminders counts how many times a verification reminder email has been sent.
|
2023-01-06 16:27:42 +00:00
|
|
|
field verification_reminders int ( updatable, default 0 )
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// failed_login_count keeps track on how many times login has failed.
|
2023-01-06 16:27:42 +00:00
|
|
|
field failed_login_count int ( updatable, nullable )
|
2023-02-08 12:56:50 +00:00
|
|
|
// login_lockout_expiration is used when the user has failed to login too many times.
|
2023-01-06 16:27:42 +00:00
|
|
|
field login_lockout_expiration timestamp ( updatable, nullable )
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// signup_captcha is the captcha score recorded during sign-up.
|
2023-01-06 16:27:42 +00:00
|
|
|
field signup_captcha float64 ( nullable )
|
2023-06-07 10:02:07 +01:00
|
|
|
|
|
|
|
// placement to be used for every new project as default for the buckets.
|
|
|
|
field default_placement int (nullable, updatable)
|
2023-01-06 16:27:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create user ( )
|
|
|
|
update user ( where user.id = ? )
|
|
|
|
delete user ( where user.id = ? )
|
|
|
|
|
|
|
|
read all (
|
|
|
|
select user
|
|
|
|
where user.normalized_email = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select user
|
|
|
|
where user.normalized_email = ?
|
|
|
|
where user.status != 0
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select user
|
|
|
|
where user.id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select user.project_limit
|
|
|
|
where user.id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select user.paid_tier
|
|
|
|
where user.id = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select user.project_storage_limit user.project_bandwidth_limit user.project_segment_limit
|
|
|
|
where user.id = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
model webapp_session (
|
|
|
|
key id
|
|
|
|
index ( fields user_id )
|
|
|
|
|
|
|
|
field id blob
|
|
|
|
field user_id blob
|
|
|
|
field ip_address text
|
|
|
|
field user_agent text
|
|
|
|
field status int ( updatable, autoinsert )
|
|
|
|
field expires_at timestamp ( updatable )
|
|
|
|
)
|
|
|
|
|
|
|
|
create webapp_session ( )
|
|
|
|
update webapp_session ( where webapp_session.id = ? )
|
|
|
|
delete webapp_session ( where webapp_session.id = ? )
|
|
|
|
delete webapp_session ( where webapp_session.user_id = ? )
|
|
|
|
|
|
|
|
read all (
|
|
|
|
select webapp_session
|
|
|
|
where webapp_session.user_id = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select webapp_session
|
|
|
|
where webapp_session.id = ?
|
|
|
|
)
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// registration_token is used to limit user registration to the satellite.
|
2023-01-06 16:27:42 +00:00
|
|
|
model registration_token (
|
|
|
|
key secret
|
|
|
|
unique owner_id
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// secret is random identifier used during registration.
|
2023-01-06 16:27:42 +00:00
|
|
|
field secret blob
|
2023-02-08 12:56:50 +00:00
|
|
|
// owner_id is the user who claimed this token. This refers to user.id column.
|
2023-01-06 16:27:42 +00:00
|
|
|
field owner_id blob ( updatable, nullable )
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// project_limit is the default limit on how many projects the user can create.
|
2023-01-06 16:27:42 +00:00
|
|
|
field project_limit int
|
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
|
|
|
|
|
|
|
create registration_token ( )
|
|
|
|
read one (
|
|
|
|
select registration_token
|
|
|
|
where registration_token.secret = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select registration_token
|
|
|
|
where registration_token.owner_id = ?
|
|
|
|
)
|
|
|
|
update registration_token ( where registration_token.secret = ? )
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// reset_password_token is a token that is used when resetting password.
|
2023-01-06 16:27:42 +00:00
|
|
|
model reset_password_token (
|
|
|
|
key secret
|
|
|
|
unique owner_id
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// secret is sent to the users email, to verify their account.
|
2023-01-06 16:27:42 +00:00
|
|
|
field secret blob
|
2023-02-08 12:56:50 +00:00
|
|
|
// owner_id is the associated user. This refers to user.id column.
|
2023-01-06 16:27:42 +00:00
|
|
|
field owner_id blob ( updatable )
|
|
|
|
|
|
|
|
field created_at timestamp ( autoinsert )
|
|
|
|
)
|
|
|
|
|
|
|
|
create reset_password_token ( )
|
|
|
|
read one (
|
|
|
|
select reset_password_token
|
|
|
|
where reset_password_token.secret = ?
|
|
|
|
)
|
|
|
|
read one (
|
|
|
|
select reset_password_token
|
|
|
|
where reset_password_token.owner_id = ?
|
|
|
|
)
|
|
|
|
delete reset_password_token ( where reset_password_token.secret = ? )
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// account_freeze_event contains information about the user account getting
|
|
|
|
// frozen due to suspicious or bad activity.
|
2023-01-06 16:27:42 +00:00
|
|
|
model account_freeze_event (
|
|
|
|
key user_id event
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// user_id refers to user.id column.
|
2023-01-06 16:27:42 +00:00
|
|
|
field user_id blob
|
2023-10-18 19:53:54 +01:00
|
|
|
// event indicates the console.AccountFreezeEventType. BillingFreeze=0, BillingWarning=1, ViolationFreeze=2.
|
2023-02-08 12:56:50 +00:00
|
|
|
field event int
|
|
|
|
// limits are the limits before the freeze begun.
|
2023-01-06 16:27:42 +00:00
|
|
|
field limits json ( nullable, updatable )
|
2023-10-18 19:53:54 +01:00
|
|
|
// days_till_escalation is the number of days till this event is escalated.
|
|
|
|
// e.g. if the user is warned for 15 days, the escalation is billing freeze.
|
|
|
|
field days_till_escalation int ( nullable, updatable )
|
2023-02-08 12:56:50 +00:00
|
|
|
// created_at indicates when the freeze was created.
|
2023-01-06 16:27:42 +00:00
|
|
|
field created_at timestamp ( default current_timestamp )
|
|
|
|
)
|
|
|
|
|
|
|
|
create account_freeze_event( replace )
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select account_freeze_event
|
|
|
|
where account_freeze_event.user_id = ?
|
|
|
|
where account_freeze_event.event = ?
|
|
|
|
)
|
|
|
|
|
2023-02-13 17:32:39 +00:00
|
|
|
read all (
|
|
|
|
select account_freeze_event
|
|
|
|
where account_freeze_event.user_id = ?
|
|
|
|
)
|
|
|
|
|
2023-01-06 16:27:42 +00:00
|
|
|
update account_freeze_event (
|
|
|
|
where account_freeze_event.user_id = ?
|
|
|
|
where account_freeze_event.event = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
delete account_freeze_event ( where account_freeze_event.user_id = ? )
|
|
|
|
|
2023-03-23 12:04:32 +00:00
|
|
|
delete account_freeze_event (
|
|
|
|
where account_freeze_event.user_id = ?
|
|
|
|
where account_freeze_event.event = ?
|
|
|
|
)
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// user_settings table is used to persist user preferences.
|
2023-02-03 10:30:22 +00:00
|
|
|
model user_settings (
|
|
|
|
key user_id
|
|
|
|
|
2023-02-08 12:56:50 +00:00
|
|
|
// user_id refers to user.id column.
|
2023-02-03 10:30:22 +00:00
|
|
|
field user_id blob
|
2023-02-08 12:56:50 +00:00
|
|
|
// session_minutes indicates the time when the user should be logged out.
|
2023-02-03 10:30:22 +00:00
|
|
|
field session_minutes uint ( nullable, updatable )
|
2023-03-01 21:53:07 +00:00
|
|
|
// passphrase_prompt indicates whether the user would like to be prompted for a passphrase when entering or switching projects.
|
|
|
|
field passphrase_prompt bool ( nullable, updatable )
|
2023-03-15 15:46:59 +00:00
|
|
|
// onboarding_start indicates whether the user has started the onboarding flow.
|
|
|
|
field onboarding_start bool ( updatable, default true )
|
|
|
|
// onboarding_end indicates whether the user has finished/skipped the onboarding flow.
|
|
|
|
field onboarding_end bool ( updatable, default true )
|
|
|
|
// onboarding_step indicates the step where a user exited onboarding without finishing.
|
|
|
|
field onboarding_step text ( nullable, updatable )
|
2023-02-03 10:30:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
create user_settings ( noreturn )
|
|
|
|
|
|
|
|
read one (
|
|
|
|
select user_settings
|
|
|
|
where user_settings.user_id = ?
|
|
|
|
)
|
|
|
|
|
|
|
|
update user_settings ( where user_settings.user_id = ? )
|