motion-authentication 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab7ad1c6522f447bb8e957077b29e783d5ec6175d67f9f08809f2089ea4c6383
4
- data.tar.gz: aefda12e3ef3a7f8799d1d5390004a164e5379a83316fb17dcceeff3ca5d3606
3
+ metadata.gz: '0464095a62b779410bfb6f77ce4af35a4fdac0931ad70fa643ab9f760e9f0818'
4
+ data.tar.gz: 3d689a129c84e215929ce56176d3307b0eee3638f23a50960e44005808451182
5
5
  SHA512:
6
- metadata.gz: ef8b4a0d2abf1ecf42ab67df9244bbbb82b5e464fcc782e7fa6fd4655ffe88b4eb2babced62efbd5178ea9791c6e83417d61397cb03199258ac698566fb74bac
7
- data.tar.gz: 9a025671043d81dfb2a857edf810caf1964824cbb784f9ed5f32d53e10abcdf246251d9db2ae351f958921ae957a84e0d62249ac47cbc38df0c991374b3d1450
6
+ metadata.gz: a8a63d60ff70107fa47e53c24b5d99c0ec1e3c5ff81a802655ef67902372653b438f672c78bff99d474a027ba2bda2b055d5cdc6c4479b9313b78f3f9c671094
7
+ data.tar.gz: d44090efc74dec5cf872dda15c083d1ea4d20e5d6e812d48e42104cc591f09a8e72b238778097fc6816da8247a62402ff54d7422634da65dbc2a199bf58265cc
data/README.md CHANGED
@@ -10,7 +10,7 @@ Need authorization? Use [`motion-authorization`](https://github.com/rubymotion-c
10
10
 
11
11
  Add this line to your application's `Gemfile`, then run `bundle install`:
12
12
 
13
- gem 'motion-authentication'
13
+ gem 'motion-authentication', '~> 2.0'
14
14
 
15
15
  Next, run `rake pod:install` to install the CocoaPod dependencies.
16
16
 
@@ -20,7 +20,7 @@ Start by subclassing `Motion::Authentication` to create your own `Auth` class. S
20
20
 
21
21
  ```ruby
22
22
  class Auth < Motion::Authentication
23
- strategy DeviseTokenAuth
23
+ strategy DeviseCookieAuth
24
24
  sign_in_url "https://example.com/api/v1/users/sign_in"
25
25
  end
26
26
  ```
@@ -29,15 +29,15 @@ Available strategies:
29
29
 
30
30
  * `DeviseCookieAuth` - This strategy supports the default way of authenticating with Devise, just as if you were submitting the sign in form using a web browser. It works by making an initial request to fetch the authenticity token, then submits the `email` and `password`, then stores the resulting cookie for authenticating future requests. If your user model has a different name (i.e. `AdminUser`), pass along the `namespace` option (i.e. `namespace: 'admin_user'`) when calling `sign_in`. Otherwise, namespace defaults to `:user`.
31
31
 
32
- * `DeviseTokenAuth` - This authentication strategy is based on [José Valim's example gist](https://gist.github.com/josevalim/fb706b1e933ef01e4fb6) and is also in the format that Ember Simple Auth Devise adapter expects ([tutorial](http://romulomachado.github.io/2015/09/28/using-ember-simple-auth-with-devise.html))
32
+ * `DeviseSimpleTokenAuth` - This authentication strategy is based on [José Valim's example gist](https://gist.github.com/josevalim/fb706b1e933ef01e4fb6) and is compatible with the [`simple_token_authentication` gem](https://github.com/gonzalo-bulnes/simple_token_authentication), and the [Ember Simple Auth Devise adapter](http://romulomachado.github.io/2015/09/28/using-ember-simple-auth-with-devise.html).
33
33
 
34
34
  This strategy takes `email` and `password`, makes a POST request to the `sign_in_url`, and expects the response to include `email` and `token` keys in the JSON response object.
35
35
 
36
- * `DeviseTokenAuthGem` - This authentication strategy is compatible with the current version of the devise_auth_token gem at https://github.com/lynndylanhurley/devise_token_auth
36
+ * `DeviseTokenAuth` - This authentication strategy is compatible with the [`devise_token_auth` gem](https://github.com/lynndylanhurley/devise_token_auth).
37
37
 
38
- Signing up: this strategy takes `email`, `password` and `password_confirmation`, makes a POST request to the `sign_up_url`, and expects the response to include `uid`, `access-token` and `client` keys in the response object headers.
38
+ **Signing up:** this strategy takes `email`, `password` and `password_confirmation`, makes a POST request to the `sign_up_url`, and expects the response to include `uid`, `access-token` and `client` keys in the response object headers.
39
39
 
40
- Signing in: this strategy takes `email` and `password`, makes a POST request to the `sign_in_url`, and expects the response to include `uid`, `access-token` and `client` keys in the response object headers.
40
+ **Signing in:** this strategy takes `email` and `password`, makes a POST request to the `sign_in_url`, and expects the response to include `uid`, `access-token` and `client` keys in the response object headers.
41
41
 
42
42
  ### `.sign_in`
43
43
 
@@ -6,6 +6,8 @@ end
6
6
 
7
7
  require 'motion-cocoapods' # TODO: this won't work for Android
8
8
  require 'motion-keychain' # TODO: this won't work for Android
9
+ require 'motion-http'
10
+ require 'motion-html'
9
11
 
10
12
  lib_dir_path = File.dirname(File.expand_path(__FILE__))
11
13
  Motion::Project::App.setup do |app|
@@ -5,7 +5,7 @@ class Motion
5
5
 
6
6
  def strategy(val = nil)
7
7
  @strategy = val unless val.nil?
8
- @strategy ||= DeviseTokenAuth
8
+ @strategy ||= DeviseCookieAuth
9
9
  end
10
10
 
11
11
  def sign_in_url(val = nil)
@@ -1,9 +1,9 @@
1
1
  module Motion
2
2
  class Authentication
3
- class DeviseTokenAuth
3
+ class DeviseSimpleTokenAuth
4
4
  class << self
5
5
  def sign_in(sign_in_url, params, &block)
6
- AFMotion::JSON.post(sign_in_url, user: params) do |response|
6
+ HTTP.post(sign_in_url, json: { user: params }) do |response|
7
7
  if response.success?
8
8
  store_auth_tokens(response.object)
9
9
  end
@@ -12,7 +12,7 @@ module Motion
12
12
  end
13
13
 
14
14
  def sign_up(sign_up_url, params, &block)
15
- AFMotion::JSON.post(sign_up_url, user: params) do |response|
15
+ HTTP.post(sign_up_url, json: { user: params }) do |response|
16
16
  if response.success?
17
17
  store_auth_tokens(response.object)
18
18
  end
@@ -1,41 +1,38 @@
1
1
  module Motion
2
2
  class Authentication
3
- class DeviseTokenAuthGem
3
+ class DeviseTokenAuth
4
4
  class << self
5
-
6
5
  def sign_in(sign_in_url, params, &block)
7
- AFMotion::JSON.post(sign_in_url, params) do |response|
6
+ HTTP.post(sign_in_url, json: params) do |response|
8
7
  if response.success?
9
- store_auth_tokens(response.object,response.operation.response.allHeaderFields)
8
+ store_auth_tokens(response.object, response.headers)
10
9
  end
11
10
  block.call(response)
12
11
  end
13
12
  end
14
13
 
15
14
  def sign_up(sign_up_url, params, &block)
16
- AFMotion::JSON.post(sign_up_url, params) do |response|
15
+ HTTP.post(sign_up_url, json: params) do |response|
17
16
  if response.success?
18
- store_auth_tokens(response.object,response.operation.response.allHeaderFields)
17
+ store_auth_tokens(response.object, response.headers)
19
18
  end
20
19
  block.call(response)
21
20
  end
22
21
  end
23
22
 
24
- def store_auth_tokens(response,headers)
23
+ def store_auth_tokens(response, headers)
25
24
  MotionKeychain.set :auth_uid, headers["uid"]
26
25
  MotionKeychain.set :auth_token, headers["access-token"]
27
26
  MotionKeychain.set :auth_client, headers["client"]
28
27
  serialized_response = ""
29
- response["data"].each do |key,value|
28
+ response["data"].each do |key, value|
30
29
  case key
31
- when "assets"
32
- value.each do |eachasset|
33
- serialized_response << eachasset["name"] + "·" + eachasset["qty"].to_s + ","
30
+ when "assets"
31
+ value.each do |eachasset|
32
+ serialized_response << eachasset["name"] + "·" + eachasset["qty"].to_s + ","
34
33
  end
35
- when "friends"
36
- #do nothing
37
- else
38
- serialized_response << key + "·" + value.to_s + ","
34
+ else
35
+ serialized_response << key + "·" + value.to_s + ","
39
36
  end
40
37
  end
41
38
  MotionKeychain.set :current_user, serialized_response
@@ -64,7 +61,7 @@ module Motion
64
61
  block.call
65
62
  end
66
63
 
67
- def deserialize(mystring,arr_sep=',', key_sep='·')
64
+ def deserialize(mystring, arr_sep=',', key_sep='·')
68
65
  array = mystring.split(arr_sep)
69
66
  hash = {}
70
67
  array.each do |e|
@@ -73,7 +70,6 @@ module Motion
73
70
  end
74
71
  return hash
75
72
  end
76
-
77
73
  end
78
74
  end
79
75
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Havens
@@ -92,7 +92,7 @@ files:
92
92
  - lib/motion-authentication.rb
93
93
  - lib/project/motion-authentication.rb
94
94
  - lib/project/strategies/devise_cookie_auth.rb
95
- - lib/project/strategies/devise_token_auth.rb
95
+ - lib/project/strategies/devise_simple_token_auth.rb
96
96
  - lib/project/strategies/devise_token_auth_gem.rb
97
97
  homepage: https://github.com/rubymotion-community/motion-authentication
98
98
  licenses: