diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-05-08 17:25:57 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-08 17:25:57 -0500 |
commit | 7a176b3fdff7d27651b306e7550010b344dfa922 (patch) | |
tree | 368d255a28b4b8e445ee66ff7278c792acc40703 /src/state/models/ui/create-account.ts | |
parent | cdfb1c7abf02ef7896d6cdcf3566ee0c7dd390d3 (diff) | |
download | voidsky-7a176b3fdff7d27651b306e7550010b344dfa922.tar.zst |
[APP-615] COPPA-compliant signup (#570)
* Rework account creation to be COPPA compliant * Fix lint * Switch android datepicker to use the spinner mode * Fix type signatures & usages
Diffstat (limited to 'src/state/models/ui/create-account.ts')
-rw-r--r-- | src/state/models/ui/create-account.ts | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/state/models/ui/create-account.ts b/src/state/models/ui/create-account.ts index e661cb59d..3f83dd6a7 100644 --- a/src/state/models/ui/create-account.ts +++ b/src/state/models/ui/create-account.ts @@ -6,6 +6,9 @@ import {ComAtprotoServerCreateAccount} from '@atproto/api' import * as EmailValidator from 'email-validator' import {createFullHandle} from 'lib/strings/handles' import {cleanError} from 'lib/strings/errors' +import {getAge} from 'lib/strings/time' + +const DEFAULT_DATE = new Date(Date.now() - 60e3 * 60 * 24 * 365 * 20) // default to 20 years ago export class CreateAccountModel { step: number = 1 @@ -21,7 +24,7 @@ export class CreateAccountModel { email = '' password = '' handle = '' - is13 = false + birthDate = DEFAULT_DATE constructor(public rootStore: RootStoreModel) { makeAutoObservable(this, {}, {autoBind: true}) @@ -32,6 +35,13 @@ export class CreateAccountModel { next() { this.error = '' + if (this.step === 2) { + if (getAge(this.birthDate) < 13) { + this.error = + 'Unfortunately, you do not meet the requirements to create an account.' + return + } + } this.step++ } @@ -124,8 +134,7 @@ export class CreateAccountModel { return ( (!this.isInviteCodeRequired || this.inviteCode) && !!this.email && - !!this.password && - this.is13 + !!this.password ) } return !!this.handle @@ -186,7 +195,7 @@ export class CreateAccountModel { this.handle = v } - setIs13(v: boolean) { - this.is13 = v + setBirthDate(v: Date) { + this.birthDate = v } } |