Skip to content

Commit

Permalink
Release: 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
amkirwan committed Aug 8, 2015
1 parent 14e726e commit e996b3b
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 138 deletions.
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ JavaScript library for using OAuth 2.0 Implicit Grant flow (Client-Side Flow) or

This creates an OAuth 2.0 Ember object class for handling authentication with OAuth 2.0 providers.

Current Version: **[0.7.0](https://github.com/amkirwan/ember-oauth2/releases/tag/v0.7.0)**
Current Version: **[1.0.0](https://github.com/amkirwan/ember-oauth2/releases/tag/v1.0.0)**

The EmberCli addon [EmberTokenAuth](https://github.com/amkirwan/ember-token-auth) demonstrates how to use Ember-OAuth2 library for authentication.

Expand Down Expand Up @@ -150,7 +150,7 @@ Old API for handling the redirect in version <= 0.2.3 that does not use Ember.Ev
<title>Authorize</title>
<script>
var hash = window.location.hash;
window.opener.App.oauth.onRedirect(hash);
window.opener.App.oauth.trigger('redirect', hash);
window.close();
</script>
</head>
Expand Down Expand Up @@ -183,13 +183,6 @@ App.oauth.on('success', function(stateObj) { return 'hello, success' } });
App.oauth.on('error', function(err) { return 'hello, error' } });
```

Old API for the callbacks version <= 0.2.3 that does not use Ember.Evented for binding events.

```javascript
Ember.OAuth2.reopen({ onSuccess: function() { return 'hello, onSuccess' } });
Ember.OAuth2.reopen({ onError: function() { return 'hello, onError' } });
```

## Authorization Grant flow

If using the Authorization Grant flow with your provider your backend server will need to handle the final steps of authorizing your application. Your success handler will need to send the `AUTHORIZATON_CODE` returned from OAuth2 provider to your backend server which can then retrieve an access token using the client_id, client_secret, and authorization_code.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-oauth2",
"version": "0.7.0",
"version": "1.0.0",
"homepage": "https://github.com/amkirwan/ember-oauth2",
"authors": [
"Anthony Kirwan <[email protected]>"
Expand Down
77 changes: 16 additions & 61 deletions dist/ember-oauth2.amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ define("ember-oauth2",
* @overview OAuth2 library for Emberjs that stores tokens in the browsers localStorage
* @license Licensed under MIT license
* See https://raw.github.com/amkirwan/ember-oauth2/master/LICENSE
* @version 0.7.0
* @version 1.0.0
*
* @module ember-oauth2
* @class ember-oauth2
Expand Down Expand Up @@ -95,24 +95,11 @@ define("ember-oauth2",
// sets the properties from the providerConfig and overrides any default settings.
this.setProperties(this.providerConfig);

// Bind deprecated event handlers
/**
* @event redirect
* @param {function} The function that handles the redirect.
*/
this.on('redirect', this.handleRedirect);

/**
* @event success
* @param {function} The function that handles the success callback.
*/
this.on('success', this._onSuccess);

/**
* @event error
* @param {function} The function that handles the error callback.
*/
this.on('error', this._onError);
},

/**
Expand Down Expand Up @@ -238,29 +225,22 @@ define("ember-oauth2",
},

/**
@method expiresIn
@return {Number} When the token expires in seconds.
* @method expiresIn
* @param {String} expires Expires time string from params
* @return {Number} When the token expires in seconds.
*/
expiresIn: function(expires) {
return this.now() + parseInt(expires, 10);
},

/**
* call on redirect from OAuth2 provider response
@method onRedirect
@deprecated Use `.trigger('redirect')` instead.
*/
onRedirect: function(hash, callback) {
Ember.Logger.warn("Ember.OAuth2.onRedirect is deprecated and will be removed in future versions. Please use .trigger('redirect') instead.");
this.trigger('redirect', hash, callback);
},

/*
* proxy functions for old event handlers
*
* Check if the token returned is valid and if so trigger `success` event else trigger `error`
*
* @method handleRedirect
* @param {Object} hash The window location hash callback url
* @param {Function} callback Optional callback
*/
handleRedirect: function(hash, callback) {
var params = this.parseCallback(hash);
Expand All @@ -285,40 +265,6 @@ define("ember-oauth2",
}
},

/**
* This method will call the old onSuccess callback when using the old API: Ember.OAuth2.reopen({ onSuccess: function() { return 'hello, onSuccess' } });
*
* The old onSuccess method will only be called when onSuccess is defined as a function on the Ember.OAuth2 instance
*
* @method _onSuccess
* @param {Object} stateObj
* @private
*/
_onSuccess: function(stateObj) {
if (typeof(this.onSuccess) !== 'function')
return;

Ember.Logger.warn("Ember.OAuth2.onSuccess is deprecated and will be removed in future versions. Bind your callbacks using .on('success', fn) instead.");
this.onSuccess(stateObj);
},

/**
* This method will call the old onError callback when using the old API: Ember.OAuth2.reopen({ onError: function() { return 'hello, onError' } });
*
* The old onSuccess method will only be called when onError is defined as a function on the Ember.OAuth2 instance
*
* @method _onError
* @param {Object} err object
* @private
*/
_onError: function(err) {
if (typeof(this.onError) !== 'function')
return;

Ember.Logger.warn("Ember.OAuth2.onError is deprecated and will be removed in furture versions. Bind your callbacks using .on('error', fn) instead.");
this.onError(err);
},

/**
* Checks if the State returned from the server matches the state that was generated in the original request and saved in the browsers localStorage.
*
Expand Down Expand Up @@ -406,6 +352,7 @@ define("ember-oauth2",
* The key name to use for saving state to localstorage
*
* @method stateKeyName
* @return {String} The state key name used for localstorage
*/
stateKeyName: function() {
return this.get('statePrefix') + '-' + this.get('state');
Expand All @@ -416,6 +363,7 @@ define("ember-oauth2",
* The key name to use for saving the token to localstorage
*
* @method tokenKeyName
* @return {String} The token key name used for localstorage
*/
tokenKeyName: function() {
return this.get('tokenPrefix') + '-' + this.get('providerId');
Expand All @@ -437,6 +385,10 @@ define("ember-oauth2",

/**
* remove the state from localstorage
*
* @method removeState
* @param {String} stateName The keyname of the state object in localstorage
* @return {Object} The deleted state object from localstorage
*/
removeState: function(stateName) {
if (stateName) {
Expand All @@ -448,6 +400,9 @@ define("ember-oauth2",

/**
* remove the token from localstorage
*
* @method removeToken
* @return {Object} The token object in localstorage
*/
removeToken: function() {
return window.localStorage.removeItem(this.tokenKeyName());
Expand Down Expand Up @@ -504,7 +459,7 @@ define("ember-oauth2",
* @property {String} VERSION
* @final
*/
var VERSION = "0.7.0";
var VERSION = "1.0.0";

/**
* @method version
Expand Down
4 changes: 2 additions & 2 deletions dist/ember-oauth2.amd.min.js

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

Loading

0 comments on commit e996b3b

Please sign in to comment.