Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
feat(authService): changed redirection overwrite to empty string
Browse files Browse the repository at this point in the history
DEPRECATED: redirectUrl = 0 is deprecated in favor of redirectUrl = ''
  • Loading branch information
doktordirk committed Nov 2, 2016
1 parent 2a86286 commit cc8b79e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 34 deletions.
46 changes: 23 additions & 23 deletions doc/api_authService.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ Retrieves (GET) the profile from the BaseConfig.profileUrl. Accepts criteria. If

#### Parameters

| Parameter | Type | Description |
| --------- | ------------------------- | ------------------------------------- |
| criteria | {[{} / number ´/ string]} | An ID, or object of supported filters |
| Parameter | Type | Description |
| --------- | ------------------------ | ------------------------------------- |
| criteria | {[{} | number | string]} | An ID, or object of supported filters |

#### Returns

Expand All @@ -173,7 +173,7 @@ Updates the profile to the BaseConfig.profileUrl using BaseConfig.profileMethod
| Parameter | Type | Description |
| --------- | ------------------------ | ------------------------------------- |
| body | {} | The body |
| criteria | [{} / number / string] | An ID, or object of supported filters |
| criteria | [{} | number | string] | An ID, or object of supported filters |

#### Returns

Expand Down Expand Up @@ -344,15 +344,15 @@ Signup locally using BaseConfig.signupUrl either with credentials strings or an
| email | string | Passed on as email: email |
| password | string | Passed on as password: password |
| [options] | [{}] | Options object passed to aurelia-api |
| [redirectUri] | [string/0/null/undef ] | redirectUri overwrite. 0=off, null/undef=use default |
| [redirectUri] | [string] | redirectUri overwrite. '' = no redirection |

#### Parameters v2

| Parameter | Type | Description |
| ------------- | ----------------------- | ---------------------------------------------------- |
| credentials | {} | Passed on credentials object |
| [options] | [{}] | Options object passed to aurelia-api |
| [redirectUri] | [string/0/null/undef ] | redirectUri overwrite. 0=off, null/undef=use default |
| [redirectUri] | [string] | redirectUri overwrite. '' = no redirection |

#### Returns

Expand Down Expand Up @@ -393,15 +393,15 @@ Login locally using BaseConfig.loginUrl either with credentials strings or an ob
| email | string | Passed on as email: email |
| password | string | Passed on as password: password |
| [options] | [{}] | Options object passed to aurelia-api |
| [redirectUri] | [string/0/null/undef ] | redirectUri overwrite. 0=off, null/undef=use default |
| [redirectUri] | [string] | redirectUri overwrite. '' = no redirection |

#### Parameters v2

| Parameter | Type | Description |
| ------------- | ----------------------- | ---------------------------------------------------- |
| credentials | {} | Passed on credentials object |
| [options] | [{}] | Options object passed to aurelia-api |
| [redirectUri] | [string/0/null/undef ] | redirectUri overwrite. 0=off, null/undef=use default |
| [redirectUri] | [string] | redirectUri overwrite. '' = no redirection |

#### Returns

Expand Down Expand Up @@ -437,15 +437,17 @@ this.authService.login({

----------

### .logout([redirectUri])
### .logout([redirectUri [, query [, name]]])

Logout locally by deleting the authentication information from the storage. Redirects to BaseConfig.logoutRedirect if set. The redirectUri parameter overwrites the BaseConfig.logoutRedirect setting. Set to 0 it prevents redirection. Set to a string, will redirect there. If BaseConfig.logoutUrl is set, a logout request is send to the server first using the BaseConfig.logoutMethod.

#### Parameters

| Parameter | Type | Description |
| ------------- | ----------------------- | ---------------------------------------------------- |
| [redirectUri] | [string/0/null/undef ] | redirectUri overwrite. 0=off, null/undef=use default |
| Parameter | Type | Description |
| ------------- | --------- | ------------------------------------------- |
| [redirectUri] | [string] | redirectUri overwrite. '' = no redirection |
| [query] | [string] | optional query string for the uri |
| [name] | [string] | optional provider logout and state checking |

#### Returns

Expand Down Expand Up @@ -473,11 +475,11 @@ Authenticate with third-party with the BaseConfig.providers settings. The login

#### Parameters

| Parameter | Type | Description |
| ------------- | ----------------------- | ---------------------------------------------------- |
| provider | string | Provider name of BaseConfig.providers |
| [redirectUri] | [string/0/null/undef ] | redirectUri overwrite. 0=off, null/undef=use default |
| [userData] | [{}] | userData object passed to provider |
| Parameter | Type | Description |
| ------------- | --------- | ------------------------------------------ |
| provider | string | Provider name of BaseConfig.providers |
| [redirectUri] | [string] | redirectUri overwrite. '' = no redirection |
| [userData] | [{}] | userData object passed to provider |

#### Returns

Expand All @@ -498,10 +500,10 @@ Unlink third-party with the BaseConfig.providers settings. Optionally redirects

#### Parameters

| Parameter | Type | Description |
| ------------- | ----------------------- | ---------------------------------------------------- |
| provider | string | Provider name of BaseConfig.providers |
| [redirectUri] | [string/0/null/undef ] | redirectUri overwrite. 0=off, null/undef=use default |
| Parameter | Type | Description |
| ------------- | --------- | ------------------------------------------ |
| provider | string | Provider name of BaseConfig.providers |
| [redirectUri] | [string] | redirectUri overwrite. '' = no redirection |

#### Returns

Expand All @@ -517,5 +519,3 @@ this.authService.unlink('facebook', '#/facebook-post-unlink')
```

----------

*Note*: The redirectUri options might seem unusual. This is to provide backwards compatibility.
13 changes: 7 additions & 6 deletions src/authService.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export class AuthService {
* @param {[string]|{}} emailOrOptions [email | options for post request]
* @param {[string]} passwordOrRedirectUri [password | optional redirectUri overwrite]
* @param {[{}]} options [options]
* @param {[string]} redirectUri [optional redirectUri overwrite]
* @param {[string]} [redirectUri] [optional redirectUri overwrite, ''= no redirection]
*
* @return {Promise<any>} Server response as Object
*/
Expand Down Expand Up @@ -414,7 +414,7 @@ export class AuthService {
* @param {[string]|{}} emailOrCredentials email | object with signup data.
* @param {[string]} [passwordOrOptions] [password | options for post request]
* @param {[{}]} [optionsOrRedirectUri] [options | redirectUri overwrite]]
* @param {[string]} [redirectUri] [optional redirectUri overwrite]
* @param {[string]} [redirectUri] [optional redirectUri overwrite, ''= no redirection]
*
* @return {Promise<Object>|Promise<Error>} Server response as Object
*/
Expand Down Expand Up @@ -449,11 +449,12 @@ export class AuthService {
}

/**
* Logout locally and redirect to redirectUri (if set) or redirectUri of config. Sends logout request first, if set in config
* Logout locally and redirect to redirectUri (if set) or redirectUri of config.
* Sends logout request first, if set in config
*
* @param {[string]} [redirectUri] [optional redirectUri overwrite]
* @param {[string]} [query] [optional query]
* @param {[string]} [name] [optional name Name of the provider]
* @param {[string]} [redirectUri] [optional redirectUri overwrite, ''= no redirection]
* @param {[string]} [query] [optional query string for the uri]
* @param {[string]} [name] [optional name Name of the provider]
*
* @return {Promise<any>} Server response as Object
*/
Expand Down
20 changes: 15 additions & 5 deletions src/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,28 +291,38 @@ export class Authentication {
/**
* Redirect (page reload if applicable for the browsers save password option)
*
* @param {[string]} redirectUrl The redirect url
* @param {[string]} defaultRedirectUrl The defaultRedirectUrl
* @param {string} redirectUrl The redirect url. To not redirect use an empty string.
* @param {[string]} defaultRedirectUrl The defaultRedirectUrl. Used when redirectUrl is undefined
* @param {[string]} query The optional query string to add the the url
* @returns {undefined} undefined
*
* @memberOf Authentication
*/
redirect(redirectUrl?: string, defaultRedirectUrl?: string, query?: string) {
redirect(redirectUrl: string, defaultRedirectUrl?: string, query?: string) {
// stupid rule to keep it BC
if (redirectUrl === true) {
logger.warn('DEPRECATED: Setting redirectUrl === true to actually *not redirect* is deprecated. Set redirectUrl === 0 instead.');
logger.warn('DEPRECATED: Setting redirectUrl === true to actually *not redirect* is deprecated. Set redirectUrl === \'\' instead.');

return;
}

// stupid rule to keep it BC
if (redirectUrl === false) {
logger.warn('BREAKING CHANGE: Setting redirectUrl === false to actually *do redirect* is deprecated. Set redirectUrl to undefined or null to use the defaultRedirectUrl if so desired.');
}
// BC hack. explicit 0 means don't redirect. false will be added later and 0 deprecated

// BC hack. explicit 0 means don't redirect. deprecated in favor of an empty string
if (redirectUrl === 0) {
logger.warn('BREAKING CHANGE: Setting redirectUrl === 0 is deprecated. Set redirectUrl to \'\' instead.');

return;
}

// Empty string means don't redirect overwrite.
if (redirectUrl === '') {
return;
}

if (typeof redirectUrl === 'string') {
PLATFORM.location.href = encodeURI(redirectUrl + (query ? `?${buildQueryString(query)}` : ''));
} else if (defaultRedirectUrl) {
Expand Down

0 comments on commit cc8b79e

Please sign in to comment.