ember-auth-source 6.0.1 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/dist/ember-auth.js +69 -23
  2. metadata +3 -3
@@ -9,6 +9,17 @@ set$(Em, 'Auth', get$(Em, 'Object').extend(get$(Em, 'Evented'), {
9
9
  null != get$(this, '_session') || set$(this, '_session', get$(get$(Em, 'Auth'), 'Session').create({ auth: this }));
10
10
  return null != get$(this, '_module') || set$(this, '_module', get$(get$(Em, 'Auth'), 'Module').create({ auth: this }));
11
11
  },
12
+ trigger: function () {
13
+ get$(this, 'syncEvent').apply(this, arguments);
14
+ return this._super.apply(this, arguments);
15
+ },
16
+ syncEvent: function () {
17
+ get$(get$(this, '_request'), 'syncEvent').apply(get$(this, '_request'), arguments);
18
+ get$(get$(this, '_response'), 'syncEvent').apply(get$(this, '_response'), arguments);
19
+ get$(get$(this, '_strategy'), 'syncEvent').apply(get$(this, '_strategy'), arguments);
20
+ get$(get$(this, '_session'), 'syncEvent').apply(get$(this, '_session'), arguments);
21
+ return get$(get$(this, '_module'), 'syncEvent').apply(get$(this, '_module'), arguments);
22
+ },
12
23
  requestAdapter: 'jquery',
13
24
  responseAdapter: 'json',
14
25
  strategyAdapter: 'token',
@@ -53,6 +64,10 @@ set$(get$(Em, 'Auth'), 'Request', Ember.Object.extend({
53
64
  }
54
65
  return this.inject();
55
66
  },
67
+ syncEvent: function () {
68
+ if (null != get$(get$(this, 'adapter'), 'syncEvent'))
69
+ return get$(get$(this, 'adapter'), 'syncEvent').apply(get$(this, 'adapter'), arguments);
70
+ },
56
71
  signIn: function (opts) {
57
72
  var url;
58
73
  url = this.resolveUrl(get$(get$(this, 'auth'), 'signInEndPoint'));
@@ -216,6 +231,10 @@ set$(get$(Em, 'Auth'), 'Response', Ember.Object.extend({
216
231
  }
217
232
  return this.inject();
218
233
  },
234
+ syncEvent: function () {
235
+ if (null != get$(get$(this, 'adapter'), 'syncEvent'))
236
+ return get$(get$(this, 'adapter'), 'syncEvent').apply(get$(this, 'adapter'), arguments);
237
+ },
219
238
  canonicalize: function (input) {
220
239
  return set$(this, 'response', get$(this, 'adapter').canonicalize(input));
221
240
  },
@@ -253,18 +272,24 @@ var get$ = Ember.get;
253
272
  var set$ = Ember.set;
254
273
  set$(get$(Em, 'Auth'), 'Strategy', Ember.Object.extend({
255
274
  init: function () {
256
- var adapter, this$;
275
+ var adapter;
257
276
  if (!(null != get$(this, 'adapter'))) {
258
277
  adapter = get$(Em, 'String').classify(get$(get$(this, 'auth'), 'strategyAdapter'));
259
278
  if (null != get$(get$(Em, 'Auth'), 'Strategy')[adapter]) {
260
- set$(this, 'adapter', get$(get$(Em, 'Auth'), 'Strategy')[adapter].create({ auth: get$(this, 'auth') }));
279
+ return set$(this, 'adapter', get$(get$(Em, 'Auth'), 'Strategy')[adapter].create({ auth: get$(this, 'auth') }));
261
280
  } else {
262
281
  throw 'Adapter not found: Em.Auth.Strategy.' + adapter;
263
282
  }
264
283
  }
265
- return get$(this, 'auth').on('signInSuccess', (this$ = this, function () {
266
- return this$.deserialize();
267
- }));
284
+ },
285
+ syncEvent: function (name, args) {
286
+ args = 2 <= arguments.length ? [].slice.call(arguments, 1) : [];
287
+ switch (name) {
288
+ case 'signInSuccess':
289
+ this.deserialize();
290
+ }
291
+ if (null != get$(get$(this, 'adapter'), 'syncEvent'))
292
+ return get$(get$(this, 'adapter'), 'syncEvent').apply(get$(this, 'adapter'), arguments);
268
293
  },
269
294
  serialize: function (opts) {
270
295
  return get$(this, 'adapter').serialize(opts);
@@ -345,7 +370,7 @@ var get$ = Ember.get;
345
370
  var set$ = Ember.set;
346
371
  set$(get$(Em, 'Auth'), 'Session', Ember.Object.extend({
347
372
  init: function () {
348
- var adapter, this$, this$1, this$2;
373
+ var adapter, this$, this$1;
349
374
  null != get$(this, 'signedIn') || set$(this, 'signedIn', false);
350
375
  null != get$(this, 'userId') || set$(this, 'userId', null);
351
376
  null != get$(this, 'user') || set$(this, 'user', null);
@@ -360,19 +385,27 @@ set$(get$(Em, 'Auth'), 'Session', Ember.Object.extend({
360
385
  get$(this, 'auth').on('signInSuccess', (this$ = this, function () {
361
386
  return this$.start();
362
387
  }));
363
- get$(this, 'auth').on('signInSuccess', (this$1 = this, function () {
364
- return this$1.findUser();
365
- }));
366
- get$(this, 'auth').on('signOutSuccess', (this$2 = this, function () {
367
- return this$2.clear();
388
+ get$(this, 'auth').on('signOutSuccess', (this$1 = this, function () {
389
+ return this$1.clear();
368
390
  }));
369
391
  return this.inject();
370
392
  },
393
+ syncEvent: function (name, args) {
394
+ args = 2 <= arguments.length ? [].slice.call(arguments, 1) : [];
395
+ switch (name) {
396
+ case 'signInSuccess':
397
+ this.findUser();
398
+ }
399
+ if (null != get$(get$(this, 'adapter'), 'syncEvent'))
400
+ return get$(get$(this, 'adapter'), 'syncEvent').apply(get$(this, 'adapter'), arguments);
401
+ },
371
402
  findUser: Ember.observer(function () {
372
403
  var model, modelKey;
373
- if (get$(this, 'userId') && (modelKey = get$(get$(this, 'auth'), 'userModel')) && (model = Ember.get(modelKey)))
404
+ if (!(get$(this, 'signedIn') && get$(this, 'userId')))
405
+ return;
406
+ if ((modelKey = get$(get$(this, 'auth'), 'userModel')) && (model = Ember.get(modelKey)))
374
407
  return set$(this, 'user', model.find(get$(this, 'userId')));
375
- }, 'userId'),
408
+ }, 'signedIn', 'userId'),
376
409
  start: function () {
377
410
  return set$(this, 'signedIn', true);
378
411
  },
@@ -564,6 +597,18 @@ set$(get$(Em, 'Auth'), 'Module', Ember.Object.extend({
564
597
  }
565
598
  return this.inject();
566
599
  },
600
+ syncEvent: function () {
601
+ var args;
602
+ args = arguments;
603
+ return function (accum$) {
604
+ var _, module;
605
+ for (_ in get$(this, 'module')) {
606
+ module = get$(this, 'module')[_];
607
+ accum$.push(null != get$(module, 'syncEvent') ? get$(module, 'syncEvent').apply(module, args) : void 0);
608
+ }
609
+ return accum$;
610
+ }.call(this, []);
611
+ },
567
612
  inject: function () {
568
613
  var this$;
569
614
  return get$(this, 'auth').reopen({
@@ -743,19 +788,20 @@ var get$ = Ember.get;
743
788
  var set$ = Ember.set;
744
789
  set$(get$(get$(Em, 'Auth'), 'Module'), 'Rememberable', Ember.Object.extend({
745
790
  init: function () {
746
- var this$, this$1, this$2;
747
791
  null != get$(this, 'config') || set$(this, 'config', get$(get$(this, 'auth'), 'rememberable'));
748
- get$(this, 'auth').on('signInSuccess', (this$ = this, function () {
749
- return this$.remember();
750
- }));
751
- get$(this, 'auth').on('signInError', (this$1 = this, function () {
752
- return this$1.forget();
753
- }));
754
- get$(this, 'auth').on('signOutSuccess', (this$2 = this, function () {
755
- return this$2.forget();
756
- }));
757
792
  return this.patch();
758
793
  },
794
+ syncEvent: function (name, args) {
795
+ args = 2 <= arguments.length ? [].slice.call(arguments, 1) : [];
796
+ switch (name) {
797
+ case 'signInSuccess':
798
+ return this.remember();
799
+ case 'signInError':
800
+ return this.forget();
801
+ case 'signOutSuccess':
802
+ return this.forget();
803
+ }
804
+ },
759
805
  recall: function (opts) {
760
806
  var token;
761
807
  if (null == opts)
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: 6.0.1
4
+ version: 6.0.2
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-05-03 00:00:00.000000000 Z
12
+ date: 2013-05-06 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: 321111087
78
+ hash: -474131985
79
79
  required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  none: false
81
81
  requirements: