ember-auth-source 3.1.2 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/dist/ember-auth.js +78 -24
  2. metadata +3 -3
data/dist/ember-auth.js CHANGED
@@ -542,7 +542,8 @@
542
542
  rememberPeriod: 14,
543
543
  rememberAutoRecall: true,
544
544
  rememberStorage: 'cookie',
545
- urlAuthentication: false
545
+ urlAuthentication: false,
546
+ urlAuthenticationParamsKey: null
546
547
  });
547
548
 
548
549
  }).call(this);
@@ -606,14 +607,16 @@
606
607
 
607
608
  }).call(this);
608
609
  (function() {
609
- Auth.RESTAdapter = DS.RESTAdapter.extend({
610
- ajax: function(url, type, settings) {
611
- settings.url = url;
612
- settings.type = type;
613
- settings.context = this;
614
- return Auth.ajax(settings);
615
- }
616
- });
610
+ if ((typeof DS !== "undefined" && DS !== null) && (DS.RESTAdapter != null)) {
611
+ Auth.RESTAdapter = DS.RESTAdapter.extend({
612
+ ajax: function(url, type, settings) {
613
+ settings.url = url;
614
+ settings.type = type;
615
+ settings.context = this;
616
+ return Auth.ajax(settings);
617
+ }
618
+ });
619
+ }
617
620
 
618
621
  }).call(this);
619
622
  (function() {
@@ -685,7 +688,8 @@
685
688
  return localStorage.setItem('ember-auth-remember-me', token);
686
689
  case 'cookie':
687
690
  return jQuery.cookie('ember-auth-remember-me', token, {
688
- expires: Auth.Config.get('rememberPeriod')
691
+ expires: Auth.Config.get('rememberPeriod'),
692
+ path: '/'
689
693
  });
690
694
  }
691
695
  },
@@ -703,7 +707,7 @@
703
707
  (function() {
704
708
  Auth.Module.UrlAuthentication = Em.Object.create({
705
709
  authenticate: function(opts) {
706
- var data, token;
710
+ var data;
707
711
 
708
712
  if (opts == null) {
709
713
  opts = {};
@@ -711,23 +715,73 @@
711
715
  if (!Auth.Config.get('urlAuthentication')) {
712
716
  return;
713
717
  }
714
- if (!Auth.get('authToken') && (token = this.retrieveToken())) {
715
- data = {};
716
- if (opts.async != null) {
717
- data['async'] = opts.async;
718
- }
719
- data[Auth.Config.get('tokenKey')] = token;
720
- return Auth.signIn(data);
718
+ if (Auth.get('authToken')) {
719
+ return;
720
+ }
721
+ this.canonicalizeParams();
722
+ if ($.isEmptyObject(this.params)) {
723
+ return;
724
+ }
725
+ data = {};
726
+ if (opts.async != null) {
727
+ data['async'] = opts.async;
721
728
  }
729
+ data[Auth.Config.get('urlAuthenticationParamsKey')] = this.params;
730
+ return Auth.signIn(data);
722
731
  },
723
- retrieveToken: function() {
724
- var token;
732
+ retrieveParams: function() {
733
+ var key, _ref;
725
734
 
726
- token = $.url().param(Auth.Config.get('tokenKey'));
727
- if (token && token.charAt(token.length - 1) === '/') {
728
- token = token.slice(0, -1);
735
+ if (!Auth.Config.get('urlAuthentication')) {
736
+ return;
737
+ }
738
+ key = Auth.Config.get('urlAuthenticationParamsKey');
739
+ return this.params = (_ref = $.url().param(key)) != null ? _ref[key] : void 0;
740
+ },
741
+ canonicalizeParams: function(obj) {
742
+ var canonicalized, k, params, v, _i, _len;
743
+
744
+ if (obj == null) {
745
+ obj = this.params;
746
+ }
747
+ params = {};
748
+ if ($.isArray(obj)) {
749
+ for (k = _i = 0, _len = obj.length; _i < _len; k = ++_i) {
750
+ v = obj[k];
751
+ params[k] = v;
752
+ }
753
+ } else if (typeof obj !== 'object') {
754
+ params[String(obj)] = String(obj);
755
+ } else {
756
+ params = obj;
757
+ }
758
+ canonicalized = {};
759
+ for (k in params) {
760
+ v = params[k];
761
+ k = String(k);
762
+ if (k && k.charAt(k.length - 1) === '/') {
763
+ k = k.slice(0, -1);
764
+ }
765
+ if (typeof v === 'object') {
766
+ canonicalized[k] = this.canonicalizeParams(v);
767
+ } else {
768
+ v = String(v);
769
+ if (v && v.charAt(v.length - 1) === '/') {
770
+ v = v.slice(0, -1);
771
+ }
772
+ canonicalized[k] = v;
773
+ }
774
+ }
775
+ return this.params = canonicalized;
776
+ }
777
+ });
778
+
779
+ Em.Router.reopen({
780
+ init: function() {
781
+ if (Auth.Config.get('urlAuthentication')) {
782
+ Auth.Module.UrlAuthentication.retrieveParams();
729
783
  }
730
- return token;
784
+ return this._super.apply(this, arguments);
731
785
  }
732
786
  });
733
787
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-auth-source
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 4.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-15 00:00:00.000000000 Z
12
+ date: 2013-04-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ember-source
@@ -75,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  segments:
77
77
  - 0
78
- hash: -891102803
78
+ hash: 1051462237
79
79
  required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  none: false
81
81
  requirements: