ember-auth-source 6.0.5 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/dist/ember-auth.js +111 -83
- metadata +5 -29
data/dist/ember-auth.js
CHANGED
@@ -20,6 +20,39 @@ set$(Em, 'Auth', get$(Em, 'Object').extend(get$(Em, 'Evented'), {
|
|
20
20
|
get$(get$(this, '_session'), 'syncEvent').apply(get$(this, '_session'), arguments);
|
21
21
|
return get$(get$(this, '_module'), 'syncEvent').apply(get$(this, '_module'), arguments);
|
22
22
|
},
|
23
|
+
ensurePromise: function (callback) {
|
24
|
+
var cache$, deferred, ret;
|
25
|
+
if (null != (null != (cache$ = ret = callback()) ? get$(cache$, 'then') : void 0)) {
|
26
|
+
return ret;
|
27
|
+
} else {
|
28
|
+
deferred = get$(Em, 'Deferred').create();
|
29
|
+
deferred.resolve(deferred);
|
30
|
+
return deferred;
|
31
|
+
}
|
32
|
+
},
|
33
|
+
followPromise: function (ret, callback) {
|
34
|
+
if (null != (null != ret ? get$(ret, 'then') : void 0)) {
|
35
|
+
return ret.then(function () {
|
36
|
+
return callback();
|
37
|
+
});
|
38
|
+
} else {
|
39
|
+
return this.ensurePromise(function () {
|
40
|
+
return callback();
|
41
|
+
});
|
42
|
+
}
|
43
|
+
},
|
44
|
+
wrapDeferred: function (callback) {
|
45
|
+
var deferred, reject, resolve;
|
46
|
+
deferred = get$(Em, 'Deferred').create();
|
47
|
+
resolve = function () {
|
48
|
+
return deferred.resolve(deferred);
|
49
|
+
};
|
50
|
+
reject = function () {
|
51
|
+
return deferred.reject(deferred);
|
52
|
+
};
|
53
|
+
callback(resolve, reject);
|
54
|
+
return deferred;
|
55
|
+
},
|
23
56
|
requestAdapter: 'jquery',
|
24
57
|
responseAdapter: 'json',
|
25
58
|
strategyAdapter: 'token',
|
@@ -69,17 +102,26 @@ set$(get$(Em, 'Auth'), 'Request', Ember.Object.extend({
|
|
69
102
|
return get$(get$(this, 'adapter'), 'syncEvent').apply(get$(this, 'adapter'), arguments);
|
70
103
|
},
|
71
104
|
signIn: function (opts) {
|
72
|
-
var
|
73
|
-
|
74
|
-
|
105
|
+
var this$;
|
106
|
+
return get$(this, 'auth').ensurePromise((this$ = this, function () {
|
107
|
+
var url;
|
108
|
+
url = this$.resolveUrl(get$(get$(this$, 'auth'), 'signInEndPoint'));
|
109
|
+
return get$(this$, 'adapter').signIn(url, get$(get$(this$, 'auth'), '_strategy').serialize(opts));
|
110
|
+
}));
|
75
111
|
},
|
76
112
|
signOut: function (opts) {
|
77
|
-
var
|
78
|
-
|
79
|
-
|
113
|
+
var this$;
|
114
|
+
return get$(this, 'auth').ensurePromise((this$ = this, function () {
|
115
|
+
var url;
|
116
|
+
url = this$.resolveUrl(get$(get$(this$, 'auth'), 'signOutEndPoint'));
|
117
|
+
return get$(this$, 'adapter').signOut(url, get$(get$(this$, 'auth'), '_strategy').serialize(opts));
|
118
|
+
}));
|
80
119
|
},
|
81
120
|
send: function (opts) {
|
82
|
-
|
121
|
+
var this$;
|
122
|
+
return get$(this, 'auth').ensurePromise((this$ = this, function () {
|
123
|
+
return get$(this$, 'adapter').send(get$(get$(this$, 'auth'), '_strategy').serialize(opts));
|
124
|
+
}));
|
83
125
|
},
|
84
126
|
resolveUrl: function (path) {
|
85
127
|
var base;
|
@@ -624,8 +666,6 @@ void function () {
|
|
624
666
|
set$(get$(get$(Em, 'Auth'), 'Module'), 'ActionRedirectable', Ember.Object.extend({
|
625
667
|
init: function () {
|
626
668
|
null != get$(this, 'config') || set$(this, 'config', get$(get$(this, 'auth'), 'actionRedirectable'));
|
627
|
-
null != get$(this, 'initPath') || set$(this, 'initPath', null);
|
628
|
-
null != get$(this, 'isInit') || set$(this, 'isInit', true);
|
629
669
|
null != get$(this, 'signInRedir') || set$(this, 'signInRedir', null);
|
630
670
|
null != get$(this, 'signOutRedir') || set$(this, 'signOutRedir', null);
|
631
671
|
null != get$(this, 'router') || set$(this, 'router', null);
|
@@ -666,34 +706,16 @@ void function () {
|
|
666
706
|
if (!fallback)
|
667
707
|
return null;
|
668
708
|
if (!isSmart)
|
669
|
-
return
|
670
|
-
return this.get('' + env + 'Redir') ||
|
671
|
-
},
|
672
|
-
registerInitRedirect: function (routeName) {
|
673
|
-
if (!get$(this, 'isInit'))
|
674
|
-
return;
|
675
|
-
routeName = this.canonicalizeRoute(routeName);
|
676
|
-
return function (accum$) {
|
677
|
-
var env;
|
678
|
-
for (var cache$ = [
|
679
|
-
'signIn',
|
680
|
-
'signOut'
|
681
|
-
], i$ = 0, length$ = cache$.length; i$ < length$; ++i$) {
|
682
|
-
env = cache$[i$];
|
683
|
-
this.set('' + env + 'Redir', null);
|
684
|
-
accum$.push($.inArray(routeName, this.getBlacklist(env)) !== -1 ? this.set('' + env + 'Redir', [get$(this, 'config')['' + env + 'Route']]) : void 0);
|
685
|
-
}
|
686
|
-
return accum$;
|
687
|
-
}.call(this, []);
|
709
|
+
return fallback;
|
710
|
+
return this.get('' + env + 'Redir') || fallback;
|
688
711
|
},
|
689
|
-
registerRedirect: function (
|
712
|
+
registerRedirect: function (transition) {
|
690
713
|
var routeName;
|
691
|
-
routeName = this.canonicalizeRoute(
|
692
|
-
set$(this, 'isInit', false);
|
714
|
+
routeName = this.canonicalizeRoute(get$(transition, 'targetName'));
|
693
715
|
if ($.inArray(routeName, this.getBlacklist('signIn')) === -1)
|
694
|
-
set$(this, 'signInRedir',
|
716
|
+
set$(this, 'signInRedir', transition);
|
695
717
|
if ($.inArray(routeName, this.getBlacklist('signOut')) === -1)
|
696
|
-
return set$(this, 'signOutRedir',
|
718
|
+
return set$(this, 'signOutRedir', transition);
|
697
719
|
},
|
698
720
|
redirect: Ember.observer(function () {
|
699
721
|
var env, result;
|
@@ -702,38 +724,24 @@ void function () {
|
|
702
724
|
return;
|
703
725
|
switch (typeof result) {
|
704
726
|
case 'object':
|
705
|
-
return
|
727
|
+
return result.retry();
|
706
728
|
case 'string':
|
707
|
-
get$(
|
708
|
-
return get$(this, 'router').handleURL(result);
|
729
|
+
return get$(this, 'router').transitionTo(result);
|
709
730
|
}
|
710
731
|
}, 'auth.signedIn'),
|
711
732
|
patch: function () {
|
712
733
|
var self;
|
713
734
|
self = this;
|
714
|
-
get$(Em, 'Route').reopen({
|
715
|
-
activate: function () {
|
716
|
-
this._super.apply(this, arguments);
|
717
|
-
self.router || (self.router = get$(this, 'router'));
|
718
|
-
return self.registerInitRedirect(get$(this, 'routeName'));
|
719
|
-
}
|
720
|
-
});
|
721
|
-
return get$(Em, 'Router').reopen({
|
735
|
+
return get$(Em, 'Route').reopen({
|
722
736
|
init: function () {
|
723
|
-
|
724
|
-
return
|
725
|
-
},
|
726
|
-
transitionTo: function () {
|
727
|
-
var args;
|
728
|
-
args = Array.prototype.slice.call(arguments);
|
729
|
-
self.registerRedirect(args);
|
730
|
-
return this._super.apply(this, args);
|
737
|
+
self.router || (self.router = get$(this, 'router'));
|
738
|
+
return this._super.apply(this, arguments);
|
731
739
|
},
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
740
|
+
beforeModel: function (transition) {
|
741
|
+
return get$(self, 'auth').followPromise(this._super.apply(this, arguments), function () {
|
742
|
+
self.registerRedirect(transition);
|
743
|
+
return null;
|
744
|
+
});
|
737
745
|
}
|
738
746
|
});
|
739
747
|
}
|
@@ -750,12 +758,14 @@ set$(get$(get$(Em, 'Auth'), 'Module'), 'AuthRedirectable', Ember.Object.extend({
|
|
750
758
|
var self;
|
751
759
|
self = this;
|
752
760
|
set$(this, 'AuthRedirectable', Ember.Mixin.create({
|
753
|
-
|
754
|
-
this
|
755
|
-
|
761
|
+
beforeModel: function () {
|
762
|
+
var this$;
|
763
|
+
return get$(self, 'auth').followPromise(this._super.apply(this, arguments), (this$ = this, function () {
|
764
|
+
if (get$(get$(self, 'auth'), 'signedIn'))
|
765
|
+
return;
|
756
766
|
get$(self, 'auth').trigger('authAccess');
|
757
|
-
return this
|
758
|
-
}
|
767
|
+
return this$.transitionTo(get$(get$(self, 'config'), 'route'));
|
768
|
+
}));
|
759
769
|
}
|
760
770
|
}));
|
761
771
|
return set$(get$(this, 'auth'), 'AuthRedirectable', get$(this, 'AuthRedirectable'));
|
@@ -801,15 +811,24 @@ set$(get$(get$(Em, 'Auth'), 'Module'), 'Rememberable', Ember.Object.extend({
|
|
801
811
|
}
|
802
812
|
},
|
803
813
|
recall: function (opts) {
|
804
|
-
var
|
814
|
+
var this$;
|
805
815
|
if (null == opts)
|
806
816
|
opts = {};
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
817
|
+
return get$(this, 'auth').wrapDeferred((this$ = this, function (resolve, reject) {
|
818
|
+
var token;
|
819
|
+
if (!get$(get$(this$, 'auth'), 'signedIn') && (token = this$.retrieveToken())) {
|
820
|
+
set$(this$, 'fromRecall', true);
|
821
|
+
opts.data || (opts.data = {});
|
822
|
+
get$(opts, 'data')[get$(get$(this$, 'config'), 'tokenKey')] = token;
|
823
|
+
return get$(this$, 'auth').signIn(opts).then(function () {
|
824
|
+
return resolve();
|
825
|
+
}, function () {
|
826
|
+
return reject();
|
827
|
+
});
|
828
|
+
} else {
|
829
|
+
return resolve();
|
830
|
+
}
|
831
|
+
}));
|
813
832
|
},
|
814
833
|
remember: function () {
|
815
834
|
var token;
|
@@ -838,10 +857,11 @@ set$(get$(get$(Em, 'Auth'), 'Module'), 'Rememberable', Ember.Object.extend({
|
|
838
857
|
var self;
|
839
858
|
self = this;
|
840
859
|
return get$(Em, 'Route').reopen({
|
841
|
-
|
842
|
-
this._super.apply(this, arguments)
|
843
|
-
|
844
|
-
|
860
|
+
beforeModel: function () {
|
861
|
+
return get$(self, 'auth').followPromise(this._super.apply(this, arguments), function () {
|
862
|
+
if (get$(get$(self, 'config'), 'autoRecall') && !get$(get$(self, 'auth'), 'signedIn'))
|
863
|
+
return self.recall();
|
864
|
+
});
|
845
865
|
}
|
846
866
|
});
|
847
867
|
}
|
@@ -1130,15 +1150,22 @@ void function () {
|
|
1130
1150
|
return this.patch();
|
1131
1151
|
},
|
1132
1152
|
authenticate: function (opts) {
|
1153
|
+
var this$;
|
1133
1154
|
if (null == opts)
|
1134
1155
|
opts = {};
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1156
|
+
return get$(this, 'auth').wrapDeferred((this$ = this, function (resolve, reject) {
|
1157
|
+
if (get$(get$(this$, 'auth'), 'signedIn'))
|
1158
|
+
return resolve();
|
1159
|
+
this$.canonicalizeParams();
|
1160
|
+
if ($.isEmptyObject(get$(this$, 'params')))
|
1161
|
+
return resolve();
|
1162
|
+
set$(opts, 'data', $.extend(true, get$(this$, 'params'), get$(opts, 'data') || {}));
|
1163
|
+
return get$(this$, 'auth').signIn(opts).then(function () {
|
1164
|
+
return resolve();
|
1165
|
+
}, function () {
|
1166
|
+
return reject();
|
1167
|
+
});
|
1168
|
+
}));
|
1142
1169
|
},
|
1143
1170
|
retrieveParams: function () {
|
1144
1171
|
return set$(this, 'params', $.url().param(get$(get$(this, 'config'), 'paramsKey')));
|
@@ -1182,9 +1209,10 @@ void function () {
|
|
1182
1209
|
var self;
|
1183
1210
|
self = this;
|
1184
1211
|
get$(Em, 'Route').reopen({
|
1185
|
-
|
1186
|
-
this._super.apply(this, arguments)
|
1187
|
-
|
1212
|
+
beforeModel: function () {
|
1213
|
+
return get$(self, 'auth').followPromise(this._super.apply(this, arguments), function () {
|
1214
|
+
return self.authenticate();
|
1215
|
+
});
|
1188
1216
|
}
|
1189
1217
|
});
|
1190
1218
|
return get$(Em, 'Router').reopen({
|
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:
|
4
|
+
version: 7.0.0
|
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-
|
12
|
+
date: 2013-06-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ember-source
|
@@ -18,19 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.0.
|
22
|
-
- - ! '!='
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 1.0.0.pre4.1
|
25
|
-
- - ! '!='
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: 1.0.0.rc1.0.0
|
28
|
-
- - ! '!='
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: 1.0.0.rc1.1
|
31
|
-
- - ! '!='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.0.rc1.2
|
21
|
+
version: 1.0.0.rc6
|
34
22
|
type: :runtime
|
35
23
|
prerelease: false
|
36
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,19 +26,7 @@ dependencies:
|
|
38
26
|
requirements:
|
39
27
|
- - ! '>='
|
40
28
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0.0.
|
42
|
-
- - ! '!='
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: 1.0.0.pre4.1
|
45
|
-
- - ! '!='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 1.0.0.rc1.0.0
|
48
|
-
- - ! '!='
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: 1.0.0.rc1.1
|
51
|
-
- - ! '!='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 1.0.0.rc1.2
|
29
|
+
version: 1.0.0.rc6
|
54
30
|
description: Ember-auth source code wrapper for ruby libs.
|
55
31
|
email:
|
56
32
|
- heartsentwined@cogito-lab.com
|
@@ -75,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
51
|
version: '0'
|
76
52
|
segments:
|
77
53
|
- 0
|
78
|
-
hash:
|
54
|
+
hash: 262689745
|
79
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
56
|
none: false
|
81
57
|
requirements:
|