ember-auth-rails 3.8.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -21,6 +21,10 @@ Add `ember-auth` to sprockets. `application.js`:
21
21
 
22
22
  //= require ember-auth
23
23
 
24
+ Add the `ember-auth-source` gem to control dependencies explicitly:
25
+
26
+ $ gem install ember-auth-source --version '3.0.0'
27
+
24
28
  ## Usage
25
29
 
26
30
  See [README](https://github.com/heartsentwined/ember-auth) at the main
@@ -4,10 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'ember-auth/rails/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "ember-auth-rails"
7
+ gem.name = 'ember-auth-rails'
8
8
  gem.version = EmberAuth::Rails::VERSION
9
- gem.authors = ["heartsentwined"]
10
- gem.email = ["heartsentwined@cogito-lab.com"]
9
+ gem.authors = ['heartsentwined']
10
+ gem.email = ['heartsentwined@cogito-lab.com']
11
+ gem.date = Time.now.strftime('%Y-%m-%d')
11
12
  gem.summary = 'Ember-auth for Rails'
12
13
  gem.description = <<-EOS
13
14
  Ember-auth provides token authentication support to ember.js.
@@ -15,12 +16,13 @@ Gem::Specification.new do |gem|
15
16
  EOS
16
17
  gem.homepage = 'https://github.com/heartsentwined/ember-auth-rails'
17
18
 
18
- gem.add_dependency 'ember-rails', ['~> 0.10']
19
+ gem.add_dependency 'ember-auth-source'
20
+ gem.add_dependency 'rails'
19
21
 
20
22
  gem.files = `git ls-files`.split($/)
21
23
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
22
24
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
23
- gem.require_paths = ["lib"]
25
+ gem.require_paths = ['lib']
24
26
 
25
27
  gem.license = 'GPL-3'
26
28
  end
@@ -1,7 +1,15 @@
1
+ require 'rails'
2
+ require 'ember-auth/source'
1
3
  require 'ember-auth/rails/version'
4
+ require 'ember-auth/rails/engine'
2
5
 
3
6
  module EmberAuth
4
7
  module Rails
5
- require 'ember-auth/rails/engine'
8
+ class Railtie < ::Rails::Railtie
9
+ initializer 'ember-auth.setup-vendor', :group => :all do |app|
10
+ app.assets.append_path \
11
+ File.expand_path('../', ::EmberAuth::Source.bundled_path)
12
+ end
13
+ end
6
14
  end
7
15
  end
@@ -1,5 +1,5 @@
1
1
  module EmberAuth
2
2
  module Rails
3
- VERSION = '3.8.0'
3
+ VERSION = '4.0.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-auth-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.0
4
+ version: 4.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-03 00:00:00.000000000 Z
12
+ date: 2013-04-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: ember-rails
15
+ name: ember-auth-source
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '0.10'
21
+ version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: '0.10'
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  description: ! " Ember-auth provides token authentication support to ember.js.\n
31
47
  \ It is expected to work out of the box with rails + devise.\n"
32
48
  email:
@@ -39,14 +55,10 @@ files:
39
55
  - Gemfile
40
56
  - README.md
41
57
  - Rakefile
42
- - app/assets/javascripts/ember-auth/ember-auth.js
43
- - app/assets/javascripts/ember-auth/index.js
44
- - app/assets/javascripts/ember-auth/jquery.cookie.js
45
58
  - ember-auth-rails.gemspec
46
59
  - lib/ember-auth-rails.rb
47
60
  - lib/ember-auth/rails/engine.rb
48
61
  - lib/ember-auth/rails/version.rb
49
- - lib/ember-auth/version.rb
50
62
  homepage: https://github.com/heartsentwined/ember-auth-rails
51
63
  licenses:
52
64
  - GPL-3
@@ -60,12 +72,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
72
  - - ! '>='
61
73
  - !ruby/object:Gem::Version
62
74
  version: '0'
75
+ segments:
76
+ - 0
77
+ hash: 161159805
63
78
  required_rubygems_version: !ruby/object:Gem::Requirement
64
79
  none: false
65
80
  requirements:
66
81
  - - ! '>='
67
82
  - !ruby/object:Gem::Version
68
83
  version: '0'
84
+ segments:
85
+ - 0
86
+ hash: 161159805
69
87
  requirements: []
70
88
  rubyforge_project:
71
89
  rubygems_version: 1.8.25
@@ -1,282 +0,0 @@
1
- // Generated by CoffeeScript 1.4.0
2
- (function() {
3
- var evented;
4
-
5
- evented = Em.Object.extend(Em.Evented);
6
-
7
- window.Auth = evented.create({
8
- authToken: null,
9
- currentUserId: null,
10
- currentUser: null,
11
- jqxhr: null,
12
- prevRoute: null,
13
- signIn: function(data) {
14
- var async,
15
- _this = this;
16
- if (data == null) {
17
- data = {};
18
- }
19
- async = data.async != null ? data.async : true;
20
- if (data.async != null) {
21
- delete data['async'];
22
- }
23
- return this.ajax(this.resolveUrl(Auth.Config.get('tokenCreateUrl')), 'POST', {
24
- data: data,
25
- async: async
26
- }).done(function(json, status, jqxhr) {
27
- var model;
28
- _this.set('authToken', json[Auth.Config.get('tokenKey')]);
29
- _this.set('currentUserId', json[Auth.Config.get('idKey')]);
30
- if (model = Auth.Config.get('userModel')) {
31
- _this.set('currentUser', model.find(_this.get('currentUserId')));
32
- }
33
- _this.set('json', json);
34
- _this.set('jqxhr', jqxhr);
35
- return _this.trigger('signInSuccess');
36
- }).fail(function(jqxhr) {
37
- _this.set('jqxhr', jqxhr);
38
- return _this.trigger('signInError');
39
- }).always(function(jqxhr) {
40
- _this.set('prevRoute', null);
41
- _this.set('jqxhr', jqxhr);
42
- return _this.trigger('signInComplete');
43
- });
44
- },
45
- signOut: function(data) {
46
- var async,
47
- _this = this;
48
- if (data == null) {
49
- data = {};
50
- }
51
- data[Auth.Config.get('tokenKey')] = this.get('authToken');
52
- async = data.async != null ? data.async : true;
53
- if (data.async != null) {
54
- delete data['async'];
55
- }
56
- return this.ajax(this.resolveUrl(Auth.Config.get('tokenDestroyUrl')), 'DELETE', {
57
- data: data,
58
- async: async
59
- }).done(function(json, status, jqxhr) {
60
- _this.set('authToken', null);
61
- _this.set('currentUserId', null);
62
- _this.set('currentUser', null);
63
- _this.set('jqxhr', jqxhr);
64
- return _this.trigger('signOutSuccess');
65
- }).fail(function(jqxhr) {
66
- _this.set('jqxhr', jqxhr);
67
- return _this.trigger('signOutError');
68
- }).always(function(jqxhr) {
69
- _this.set('prevRoute', null);
70
- _this.set('jqxhr', jqxhr);
71
- return _this.trigger('signOutComplete');
72
- });
73
- },
74
- resolveUrl: function(path) {
75
- var base;
76
- base = Auth.Config.get('baseUrl');
77
- if (base && base[base.length - 1] === '/') {
78
- base = base.substr(0, base.length - 1);
79
- }
80
- if ((path != null ? path[0] : void 0) === '/') {
81
- path = path.substr(1, path.length);
82
- }
83
- return [base, path].join('/');
84
- },
85
- resolveRedirectRoute: function(type) {
86
- var fallback, isSmart, sameRoute, typeClassCase;
87
- if (type !== 'signIn' && type !== 'signOut') {
88
- return null;
89
- }
90
- typeClassCase = "" + (type[0].toUpperCase()) + (type.slice(1));
91
- isSmart = Auth.Config.get("smart" + typeClassCase + "Redirect");
92
- fallback = Auth.Config.get("" + type + "RedirectFallbackRoute");
93
- sameRoute = Auth.Config.get("" + type + "Route");
94
- if (!isSmart) {
95
- return fallback;
96
- }
97
- if (!(this.prevRoute != null) || this.prevRoute === sameRoute) {
98
- return fallback;
99
- } else {
100
- return this.prevRoute;
101
- }
102
- },
103
- ajax: function(url, type, hash) {
104
- var token;
105
- if (token = this.get('authToken')) {
106
- if (Auth.Config.get('requestHeaderAuthorization')) {
107
- hash.headers || (hash.headers = {});
108
- hash.headers[Auth.Config.get('requestHeaderKey')] = this.get('authToken');
109
- } else {
110
- hash.data || (hash.data = {});
111
- hash.data[Auth.Config.get('tokenKey')] = this.get('authToken');
112
- }
113
- }
114
- hash.url = url;
115
- hash.type = type;
116
- hash.dataType = 'json';
117
- hash.contentType = 'application/json; charset=utf-8';
118
- if (hash.data && type !== 'GET') {
119
- hash.data = JSON.stringify(hash.data);
120
- }
121
- return jQuery.ajax(hash);
122
- }
123
- });
124
-
125
- Auth.Config = Em.Object.create({
126
- tokenCreateUrl: null,
127
- tokenDestroyUrl: null,
128
- tokenKey: null,
129
- idKey: null,
130
- userModel: null,
131
- baseUrl: null,
132
- requestHeaderAuthorization: false,
133
- requestHeaderKey: null,
134
- signInRoute: null,
135
- signOutRoute: null,
136
- authRedirect: false,
137
- smartSignInRedirect: false,
138
- smartSignOutRedirect: false,
139
- signInRedirectFallbackRoute: 'index',
140
- signOutRedirectFallbackRoute: 'index',
141
- rememberMe: false,
142
- rememberTokenKey: null,
143
- rememberPeriod: 14,
144
- rememberAutoRecall: true,
145
- rememberUsingLocalStorage: false
146
- });
147
-
148
- Auth.Route = Em.Route.extend(Em.Evented, {
149
- redirect: function() {
150
- if (!Auth.get('authToken')) {
151
- this.trigger('authAccess');
152
- if (Auth.Config.get('authRedirect')) {
153
- Auth.set('prevRoute', this.routeName);
154
- return this.transitionTo(Auth.Config.get('signInRoute'));
155
- }
156
- }
157
- }
158
- });
159
-
160
- Auth.SignInController = Em.ObjectController.extend({
161
- registerRedirect: function() {
162
- return Auth.addObserver('authToken', this, 'smartSignInRedirect');
163
- },
164
- smartSignInRedirect: function() {
165
- if (Auth.get('authToken')) {
166
- this.get('target.router').transitionTo(Auth.resolveRedirectRoute('signIn'));
167
- return Auth.removeObserver('authToken', this, 'smartSignInRedirect');
168
- }
169
- }
170
- });
171
-
172
- Auth.SignOutController = Em.ObjectController.extend({
173
- registerRedirect: function() {
174
- return Auth.addObserver('authToken', this, 'smartSignOutRedirect');
175
- },
176
- smartSignOutRedirect: function() {
177
- if (!Auth.get('authToken')) {
178
- this.get('target.router').transitionTo(Auth.resolveRedirectRoute('signOut'));
179
- return Auth.removeObserver('authToken', this, 'smartSignOutRedirect');
180
- }
181
- }
182
- });
183
-
184
- Auth.RESTAdapter = DS.RESTAdapter.extend({
185
- ajax: function(url, type, hash) {
186
- hash.context = this;
187
- return Auth.ajax(url, type, hash);
188
- }
189
- });
190
-
191
- Auth.Module = Em.Object.create();
192
-
193
- Auth.Module.RememberMe = Em.Object.create({
194
- init: function() {
195
- var _this = this;
196
- Auth.on('signInSuccess', function() {
197
- return _this.remember();
198
- });
199
- Auth.on('signInError', function() {
200
- return _this.forget();
201
- });
202
- return Auth.on('signOutSuccess', function() {
203
- return _this.forget();
204
- });
205
- },
206
- recall: function(opts) {
207
- var data, token;
208
- if (opts == null) {
209
- opts = {};
210
- }
211
- if (!Auth.Config.get('rememberMe')) {
212
- return;
213
- }
214
- if (!Auth.get('authToken') && (token = this.retrieveToken())) {
215
- data = {};
216
- if (opts.async != null) {
217
- data['async'] = opts.async;
218
- }
219
- data[Auth.Config.get('rememberTokenKey')] = token;
220
- return Auth.signIn(data);
221
- }
222
- },
223
- remember: function() {
224
- var token;
225
- if (!Auth.Config.get('rememberMe')) {
226
- return;
227
- }
228
- token = Auth.get('json')[Auth.Config.get('rememberTokenKey')];
229
- if (token && token !== this.retrieveToken()) {
230
- return this.storeToken(token);
231
- }
232
- },
233
- forget: function() {
234
- if (!Auth.Config.get('rememberMe')) {
235
- return;
236
- }
237
- return this.removeToken();
238
- },
239
- retrieveToken: function() {
240
- if (Auth.Config.get('rememberUsingLocalStorage')) {
241
- return localStorage.getItem('ember-auth-remember-me');
242
- } else {
243
- return $.cookie('ember-auth-remember-me');
244
- }
245
- },
246
- storeToken: function(token) {
247
- if (Auth.Config.get('rememberUsingLocalStorage')) {
248
- return localStorage.setItem('ember-auth-remember-me', token);
249
- } else {
250
- return $.cookie('ember-auth-remember-me', token, {
251
- expires: Auth.Config.get('rememberPeriod')
252
- });
253
- }
254
- },
255
- removeToken: function() {
256
- if (Auth.Config.get('rememberUsingLocalStorage')) {
257
- return localStorage.removeItem('ember-auth-remember-me');
258
- } else {
259
- return $.removeCookie('ember-auth-remember-me');
260
- }
261
- }
262
- });
263
-
264
- Auth.Route.reopen({
265
- redirect: function() {
266
- var callback, request, self;
267
- if (Auth.Config.get('rememberMe') && Auth.Config.get('rememberAutoRecall')) {
268
- if (request = Auth.Module.RememberMe.recall({
269
- async: false
270
- })) {
271
- self = this;
272
- callback = this._super;
273
- return request.always(function() {
274
- return callback.call(self);
275
- });
276
- }
277
- }
278
- return this._super();
279
- }
280
- });
281
-
282
- }).call(this);
@@ -1,2 +0,0 @@
1
- //= require ./jquery.cookie
2
- //= require ./ember-auth
@@ -1,92 +0,0 @@
1
- /*!
2
- * jQuery Cookie Plugin v1.3.1
3
- * https://github.com/carhartl/jquery-cookie
4
- *
5
- * Copyright 2013 Klaus Hartl
6
- * Released under the MIT license
7
- */
8
- (function (factory) {
9
- if (typeof define === 'function' && define.amd && define.amd.jQuery) {
10
- // AMD. Register as anonymous module.
11
- define(['jquery'], factory);
12
- } else {
13
- // Browser globals.
14
- factory(jQuery);
15
- }
16
- }(function ($) {
17
-
18
- var pluses = /\+/g;
19
-
20
- function raw(s) {
21
- return s;
22
- }
23
-
24
- function decoded(s) {
25
- return decodeURIComponent(s.replace(pluses, ' '));
26
- }
27
-
28
- function converted(s) {
29
- if (s.indexOf('"') === 0) {
30
- // This is a quoted cookie as according to RFC2068, unescape
31
- s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
32
- }
33
- try {
34
- return config.json ? JSON.parse(s) : s;
35
- } catch(er) {}
36
- }
37
-
38
- var config = $.cookie = function (key, value, options) {
39
-
40
- // write
41
- if (value !== undefined) {
42
- options = $.extend({}, config.defaults, options);
43
-
44
- if (typeof options.expires === 'number') {
45
- var days = options.expires, t = options.expires = new Date();
46
- t.setDate(t.getDate() + days);
47
- }
48
-
49
- value = config.json ? JSON.stringify(value) : String(value);
50
-
51
- return (document.cookie = [
52
- encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
53
- options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
54
- options.path ? '; path=' + options.path : '',
55
- options.domain ? '; domain=' + options.domain : '',
56
- options.secure ? '; secure' : ''
57
- ].join(''));
58
- }
59
-
60
- // read
61
- var decode = config.raw ? raw : decoded;
62
- var cookies = document.cookie.split('; ');
63
- var result = key ? undefined : {};
64
- for (var i = 0, l = cookies.length; i < l; i++) {
65
- var parts = cookies[i].split('=');
66
- var name = decode(parts.shift());
67
- var cookie = decode(parts.join('='));
68
-
69
- if (key && key === name) {
70
- result = converted(cookie);
71
- break;
72
- }
73
-
74
- if (!key) {
75
- result[name] = converted(cookie);
76
- }
77
- }
78
-
79
- return result;
80
- };
81
-
82
- config.defaults = {};
83
-
84
- $.removeCookie = function (key, options) {
85
- if ($.cookie(key) !== undefined) {
86
- $.cookie(key, '', $.extend(options, { expires: -1 }));
87
- return true;
88
- }
89
- return false;
90
- };
91
-
92
- }));
@@ -1,3 +0,0 @@
1
- module EmberAuth
2
- VERSION = '2.6.0'
3
- end