Skip to content

Commit

Permalink
Allow skipping email addresses in signup (#18960)
Browse files Browse the repository at this point in the history
  • Loading branch information
pzduniak committed Aug 16, 2019
1 parent c881b19 commit 6675e1a
Show file tree
Hide file tree
Showing 27 changed files with 464 additions and 258 deletions.
10 changes: 2 additions & 8 deletions shared/actions/__tests__/signup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe('checkedUsername', () => {
})

it('shows error', () => {
const state = Constants.makeState({email: 'email@email.com', username: 'username'})
const state = Constants.makeState({username: 'username'})
const action = SignupGen.createCheckedUsername({
error: 'another problem',
username: state.username,
Expand All @@ -204,7 +204,7 @@ describe('checkedUsername', () => {
})

it('shows device name page on success', () => {
const state = Constants.makeState({email: 'email@email.com', username: 'username'})
const state = Constants.makeState({username: 'username'})
const action = SignupGen.createCheckedUsername({
error: '',
username: state.username,
Expand Down Expand Up @@ -309,18 +309,12 @@ describe('actually sign up', () => {

const validSignup = Constants.makeState({
devicename: 'a valid devicename',
email: 'test@test.com',
inviteCode: '1234566',
username: 'testuser',
})

const signupError = new Error('Missing data for signup')

it('bails on missing email', () => {
expect(() =>
_testing.reallySignupOnNoErrors(makeTypedState(validSignup.set('email', ''))).next()
).toThrow(signupError)
})
it('bails on missing devicename', () => {
expect(() =>
_testing.reallySignupOnNoErrors(makeTypedState(validSignup.set('devicename', ''))).next()
Expand Down
3 changes: 3 additions & 0 deletions shared/actions/json/people.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"markViewed": {},
"skipTodo": {
"type": "Types.TodoType"
},
"setResentEmail": {
"email": "string"
}
}
}
4 changes: 2 additions & 2 deletions shared/actions/json/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"actions": {
"addPhoneNumber": {
"_description": "Add a phone number and kick off a text message with a verification code.",
"allowSearch": "boolean",
"searchable": "boolean",
"phoneNumber": "string"
},
"addedPhoneNumber": {
"_description": "We just attempted to add a phone number and either got an error or the number is pending verification.",
"allowSearch": "boolean",
"searchable": "boolean",
"error?": "string",
"phoneNumber": "string"
},
Expand Down
7 changes: 3 additions & 4 deletions shared/actions/json/signup.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
"usernameTaken?": "string",
"error": "string"
},
"checkEmail": {
"allowSearch": "boolean",
"email": "string"
},
"requestInvite": {
"email": "string",
"name": "string"
Expand Down Expand Up @@ -64,6 +60,9 @@
"error": "string"
}
},
"setJustSignedUpEmail": {
"email": "string"
},
"clearJustSignedUpEmail": {}
}
}
11 changes: 11 additions & 0 deletions shared/actions/people-gen.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions shared/actions/settings-gen.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions shared/actions/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -621,22 +621,22 @@ const addPhoneNumber = async (
logger: Saga.SagaLogger
) => {
logger.info('adding phone number')
const {phoneNumber, allowSearch} = action.payload
const visibility = allowSearch ? RPCTypes.IdentityVisibility.public : RPCTypes.IdentityVisibility.private
const {phoneNumber, searchable} = action.payload
const visibility = searchable ? RPCTypes.IdentityVisibility.public : RPCTypes.IdentityVisibility.private
try {
await RPCTypes.phoneNumbersAddPhoneNumberRpcPromise(
{phoneNumber, visibility},
Constants.addPhoneNumberWaitingKey
)
logger.info('success')
return SettingsGen.createAddedPhoneNumber({allowSearch, phoneNumber})
return SettingsGen.createAddedPhoneNumber({phoneNumber, searchable})
} catch (err) {
logger.warn('error ', err.message)
const message =
err.code === RPCTypes.StatusCode.scratelimit
? 'Sorry, added a few too many phone numbers recently. Please try again later.'
: err.message
return SettingsGen.createAddedPhoneNumber({allowSearch, error: message, phoneNumber})
return SettingsGen.createAddedPhoneNumber({error: message, phoneNumber, searchable})
}
}

Expand Down
18 changes: 10 additions & 8 deletions shared/actions/signup-gen.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 7 additions & 11 deletions shared/actions/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ const showInviteScreen = () => RouteTreeGen.createNavigateAppend({path: ['signup
const showInviteSuccessOnNoErrors = (state: Container.TypedState) =>
noErrors(state) && RouteTreeGen.createNavigateAppend({path: ['signupRequestInviteSuccess']})

const showEmailScreenOnNoErrors = (state: Container.TypedState) =>
noErrors(state) && RouteTreeGen.createNavigateAppend({path: ['signupEnterEmail']})

const showDeviceScreenOnNoErrors = (state: Container.TypedState) =>
noErrors(state) && RouteTreeGen.createNavigateAppend({path: ['signupEnterDevicename']})

Expand Down Expand Up @@ -156,10 +153,10 @@ function* reallySignupOnNoErrors(state: Container.TypedState): Saga.SagaGenerato
return
}

const {email, username, inviteCode, devicename} = state.signup
const {username, inviteCode, devicename} = state.signup

if (!email || !username || !inviteCode || !devicename) {
logger.warn('Missing data during signup phase', email, username, inviteCode, devicename)
if (!username || !inviteCode || !devicename) {
logger.warn('Missing data during signup phase', username, inviteCode, devicename)
throw new Error('Missing data for signup')
}

Expand All @@ -178,13 +175,13 @@ function* reallySignupOnNoErrors(state: Container.TypedState): Saga.SagaGenerato
params: {
deviceName: devicename,
deviceType: isMobile ? RPCTypes.DeviceType.mobile : RPCTypes.DeviceType.desktop,
email,
email: '',
genPGPBatch: false,
genPaper: false,
inviteCode,
passphrase: '',
randomPw: true,
skipMail: false,
skipMail: true,
storeSecret: true,
username,
verifyEmail: true,
Expand All @@ -205,10 +202,9 @@ const signupSaga = function*(): Saga.SagaGenerator<any, any> {
yield* Saga.chainAction2([SignupGen.requestedAutoInvite, SignupGen.checkInviteCode], checkInviteCode)
yield* Saga.chainAction2(SignupGen.checkDevicename, checkDevicename)

// move to next screen actions\
// move to next screen actions
yield* Saga.chainAction2(SignupGen.requestedInvite, showInviteSuccessOnNoErrors)
yield* Saga.chainAction2(SignupGen.checkedUsername, showEmailScreenOnNoErrors)
yield* Saga.chainAction2(SignupGen.checkEmail, showDeviceScreenOnNoErrors)
yield* Saga.chainAction2(SignupGen.checkedUsername, showDeviceScreenOnNoErrors)
yield* Saga.chainAction2(SignupGen.requestedAutoInvite, showInviteScreen)
yield* Saga.chainAction2(SignupGen.checkedInviteCode, showUserOnNoErrors)
yield* Saga.chainAction2(SignupGen.signedup, showErrorOrCleanupAfterSignup)
Expand Down
3 changes: 2 additions & 1 deletion shared/actions/typed-actions-gen.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions shared/constants/people.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ export const makeState = I.Record<Types._State>({
lastViewed: new Date(),
newItems: I.List(),
oldItems: I.List(),
resentEmail: '',
version: -1,
})

Expand Down
2 changes: 2 additions & 0 deletions shared/constants/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const devicename =
(isLinux && 'My Linux Device') ||
(isMobile ? 'Mobile Device' : 'Home Computer')

export const noEmail = 'NOEMAIL'

export const makeState = I.Record<Types._State>({
devicename,
devicenameError: '',
Expand Down
1 change: 1 addition & 0 deletions shared/constants/types/people.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export type _State = {
newItems: I.List<PeopleScreenItem>
oldItems: I.List<PeopleScreenItem>
followSuggestions: I.List<FollowSuggestion>
resentEmail: string
}

export type State = I.RecordOf<_State>
2 changes: 1 addition & 1 deletion shared/people/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export type Props = {
getData: (markViewed?: boolean) => void
onClickUser: (username: string) => void
onOpenAccountSwitcher?: () => void
signupEmail: string
showAirdrop: boolean
signupEmail: string
myUsername: string
waiting: boolean
}
Expand Down
Loading

0 comments on commit 6675e1a

Please sign in to comment.