Skip to content

Commit

Permalink
Merge pull request #23 from eessex/userId
Browse files Browse the repository at this point in the history
Separate input arg interfaces, userId casing
  • Loading branch information
eessex authored Apr 22, 2020
2 parents 2a98180 + 389af75 commit dfa5a6b
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 33 deletions.
28 changes: 22 additions & 6 deletions src/Events/Authentication/CreatedAccount.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
import { ActionType, AuthModalType } from "../../Schema"
import {
ActionType,
AuthModalType,
AuthContextModule,
AuthIntent,
AuthService,
} from "../../Schema"
import { CreatedAccount } from "../../Schema/Event"
import { AccountArgs } from "./Typings"

export interface CreatedAccountArgs {
authRedirect: string
contextModule: AuthContextModule
copy?: string
intent: AuthIntent
onboarding?: boolean
service: AuthService
triggerSeconds?: number
userId: string
}

/**
* Action fired when a user creates an account
Expand All @@ -15,7 +31,7 @@ import { AccountArgs } from "./Typings"
* onboarding: true,
* service: AuthService.email,
* triggerSeconds: 3,
* user_id: "5bd8b675776bd6002c86526c"
* userId: "5bd8b675776bd6002c86526c"
* })
* ```
*/
Expand All @@ -27,8 +43,8 @@ export const createdAccount = ({
onboarding,
service,
triggerSeconds,
user_id,
}: AccountArgs): CreatedAccount => {
userId,
}: CreatedAccountArgs): CreatedAccount => {
return {
action: ActionType.createdAccount,
auth_redirect: authRedirect,
Expand All @@ -39,6 +55,6 @@ export const createdAccount = ({
service,
trigger: (triggerSeconds && "timed") || "click",
type: AuthModalType.signup,
user_id,
user_id: userId,
}
}
27 changes: 21 additions & 6 deletions src/Events/Authentication/SuccessfullyLoggedIn.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import { ActionType, AuthModalType } from "../../Schema"
import {
ActionType,
AuthModalType,
AuthContextModule,
AuthIntent,
AuthService,
} from "../../Schema"
import { SuccessfullyLoggedIn } from "../../Schema/Event"
import { AccountArgs } from "./Typings"

export interface SuccessfullyLoggedInArgs {
authRedirect: string
contextModule: AuthContextModule
copy?: string
intent: AuthIntent
service: AuthService
triggerSeconds?: number
userId: string
}

/**
* Action fired when a user logs into an existing account
Expand All @@ -14,7 +29,7 @@ import { AccountArgs } from "./Typings"
* intent: AuthIntent.viewEditorial,
* service: AuthService.email,
* triggerSeconds: 3,
* user_id: "5bd8b675776bd6002c86526c"
* userId: "5bd8b675776bd6002c86526c"
* })
* ```
*/
Expand All @@ -25,8 +40,8 @@ export const successfullyLoggedIn = ({
intent,
service,
triggerSeconds,
user_id,
}: AccountArgs): SuccessfullyLoggedIn => {
userId,
}: SuccessfullyLoggedInArgs): SuccessfullyLoggedIn => {
return {
action: ActionType.successfullyLoggedIn,
auth_redirect: authRedirect,
Expand All @@ -36,6 +51,6 @@ export const successfullyLoggedIn = ({
service,
trigger: (triggerSeconds && "timed") || "click",
type: AuthModalType.login,
user_id,
user_id: userId,
}
}
13 changes: 0 additions & 13 deletions src/Events/Authentication/Typings.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/Events/Authentication/__tests__/CreatedAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("createdAccount", () => {
contextModule: ContextModule.header,
intent: AuthIntent.signup,
service: "apple",
user_id: "foo",
userId: "5bd8b675776bd6002c86526c",
})

expect(args).toEqual({
Expand All @@ -21,7 +21,7 @@ describe("createdAccount", () => {
service: "apple",
trigger: "click",
type: "signup",
user_id: "foo",
user_id: "5bd8b675776bd6002c86526c",
})
})

Expand All @@ -34,7 +34,7 @@ describe("createdAccount", () => {
onboarding: true,
service: "email",
triggerSeconds: 2,
user_id: "foo",
userId: "5bd8b675776bd6002c86526c",
})

expect(args).toEqual({
Expand All @@ -47,7 +47,7 @@ describe("createdAccount", () => {
service: "email",
trigger: "timed",
type: "signup",
user_id: "foo",
user_id: "5bd8b675776bd6002c86526c",
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("successfullyLoggedIn", () => {
contextModule: ContextModule.header,
intent: AuthIntent.signup,
service: "apple",
user_id: "foo",
userId: "5bd8b675776bd6002c86526c",
})

expect(args).toEqual({
Expand All @@ -20,7 +20,7 @@ describe("successfullyLoggedIn", () => {
service: "apple",
trigger: "click",
type: "login",
user_id: "foo",
user_id: "5bd8b675776bd6002c86526c",
})
})

Expand All @@ -32,7 +32,7 @@ describe("successfullyLoggedIn", () => {
intent: AuthIntent.viewEditorial,
service: "email",
triggerSeconds: 2,
user_id: "foo",
userId: "5bd8b675776bd6002c86526c",
})

expect(args).toEqual({
Expand All @@ -44,7 +44,7 @@ describe("successfullyLoggedIn", () => {
service: "email",
trigger: "timed",
type: "login",
user_id: "foo",
user_id: "5bd8b675776bd6002c86526c",
})
})
})

0 comments on commit dfa5a6b

Please sign in to comment.