@@ -6,6 +6,14 @@ const LOGGED_OUT_AT_KEY = "__PROPEL_AUTH_LOGGED_OUT_AT"
66const AUTH_TOKEN_REFRESH_BEFORE_EXPIRATION_SECONDS = 4 * 60
77const DEBOUNCE_DURATION_FOR_REFOCUS_SECONDS = 4 * 60
88
9+ export interface RedirectToSignupOptions {
10+ postSignupRedirectUrl : string
11+ }
12+
13+ export interface RedirectToLoginOptions {
14+ postLoginRedirectUrl : string
15+ }
16+
917export interface IAuthClient {
1018 /**
1119 * If the user is logged in, this method returns an access token, the time (in seconds) that the token will expire,
@@ -28,12 +36,12 @@ export interface IAuthClient {
2836 /**
2937 * Redirects the user to the signup page.
3038 */
31- redirectToSignupPage ( ) : void
39+ redirectToSignupPage ( options ?: RedirectToSignupOptions ) : void
3240
3341 /**
3442 * Redirects the user to the login page.
3543 */
36- redirectToLoginPage ( ) : void
44+ redirectToLoginPage ( options ?: RedirectToLoginOptions ) : void
3745
3846 /**
3947 * Redirects the user to the account page.
@@ -230,12 +238,22 @@ export function createClient(authOptions: IAuthOptions): IAuthClient {
230238 }
231239 } ,
232240
233- redirectToSignupPage ( ) : void {
234- window . location . href = `${ clientState . authUrl } /signup`
241+ redirectToSignupPage ( options ?: RedirectToSignupOptions ) : void {
242+ let qs = ""
243+ if ( options && options . postSignupRedirectUrl ) {
244+ const encode = window ? window . btoa : btoa ;
245+ qs = new URLSearchParams ( { "rt" : encode ( options . postSignupRedirectUrl ) } ) . toString ( )
246+ }
247+ window . location . href = `${ clientState . authUrl } /signup?${ qs } `
235248 } ,
236249
237- redirectToLoginPage ( ) : void {
238- window . location . href = `${ clientState . authUrl } /login`
250+ redirectToLoginPage ( options ?: RedirectToLoginOptions ) : void {
251+ let qs = ""
252+ if ( options && options . postLoginRedirectUrl ) {
253+ const encode = window ? window . btoa : btoa ;
254+ qs = new URLSearchParams ( { "rt" : encode ( options . postLoginRedirectUrl ) } ) . toString ( )
255+ }
256+ window . location . href = `${ clientState . authUrl } /login?${ qs } `
239257 } ,
240258
241259 redirectToAccountPage ( ) : void {
0 commit comments