Skip to content

Commit

Permalink
returnTo for password reset et signup (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbersac authored Feb 5, 2020
1 parent 4962c4e commit 7bf003f
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/main/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ import { popupSize } from './providerPopupSize'
import { createHttpClient, HttpClient } from './httpClient'
import { computePkceParams, PkceParams } from './pkceService'

export type SignupParams = { data: SignupProfile; saveCredentials?: boolean; auth?: AuthOptions; redirectUrl?: string }
export type SignupParams = {
data: SignupProfile
returnToAfterEmailConfirmation?: string
saveCredentials?: boolean
auth?: AuthOptions
redirectUrl?: string
}
export type UpdateEmailParams = { accessToken: string; email: string; redirectUrl?: string }

type LoginWithPasswordOptions = { password: string; saveCredentials?: boolean; auth?: AuthOptions }
Expand All @@ -29,7 +35,12 @@ export type LoginWithCredentialsParams = {
auth?: AuthOptions
}

type EmailRequestPasswordResetParams = { email: string; redirectUrl?: string }
type EmailRequestPasswordResetParams = {
email: string
redirectUrl?: string
loginLink?: string
returnToAfterPasswordReset?: string
}
type SmsRequestPasswordResetParams = { phoneNumber: string }
export type RequestPasswordResetParams = EmailRequestPasswordResetParams | SmsRequestPasswordResetParams

Expand Down Expand Up @@ -413,7 +424,7 @@ export default class ApiClient {
}

signup(params: SignupParams): Promise<void> {
const { data, auth, redirectUrl } = params
const { data, auth, redirectUrl, returnToAfterEmailConfirmation } = params
const acceptTos = auth && auth.acceptTos

const signupPromise = window.cordova
Expand All @@ -424,7 +435,8 @@ export default class ApiClient {
redirectUrl,
scope: this.resolveScope(auth),
...pick(auth, 'origin'),
data
data,
returnToAfterEmailConfirmation,
}
})
.then(result => this.eventManager.fireEvent('authenticated', result))
Expand All @@ -435,7 +447,8 @@ export default class ApiClient {
redirectUrl,
scope: this.resolveScope(auth),
acceptTos,
data
data,
returnToAfterEmailConfirmation,
}
})
.then(({ tkn }) => this.loginWithPasswordToken(tkn, auth))
Expand Down

0 comments on commit 7bf003f

Please sign in to comment.