api_user_auth 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e03f4578b5a4c4526a3cf16ef4f5153f2b6ba53ac614f2152140188a75ed9511
4
- data.tar.gz: fc2c4f7d22cfcf3966ae63b446a1f484c3ca3db6cd7e7f3743e00e8ce402f6c4
3
+ metadata.gz: 3c361db01eddc3c4e3679474cdedd7df1e800cb22f4053b6625f6db9cad41e6c
4
+ data.tar.gz: e47b8d653ff59fe59ac7f4c2af18fd4695fae1987ffc2d720faadb7422e684a9
5
5
  SHA512:
6
- metadata.gz: c7f7735446438b9825b2626bb747c450cab316438f748f5a8b63fc15b755110a6e8c72a00d86b742e2626b967c6867cfde622765e534ece03bf2a535874b157a
7
- data.tar.gz: 3c32189bf9ecd93bfed90fa13e6eb278e77db613f58c6d7ded4c520a4d06db497790e172c5d66ce6b9cd5cba5a3a1edc14b9450ae3b938572350d682dd6a5321
6
+ metadata.gz: b87a1ff220c0314813f57be18220b654126b64bdabcb587a3b1817be1eaef8d4cd4ee09522783add2b3f6408d28af6935d528dafa8f602727bfbe37d825606d7
7
+ data.tar.gz: 98a0559e5079d05ac82098243388fed28d4361874b47e01e73c34fd9c1675ccdb2e297a0f7378b5ec28e7e6df62aae6b3061d6573c5e231dd53a8b979fa9e954
@@ -58,8 +58,10 @@ module ApiUserAuth
58
58
  token = request.headers['Authorization'].sub(/Bearer\s*=?/, '')
59
59
  auth_user = AuthUser.find_fy_token(token)
60
60
  if auth_user.present?
61
- auth_user.add_provider_login(params)
62
- render json: {}, status: 200
61
+ prov = auth_user.add_provider_login(params)
62
+ data = {}
63
+ data["#{prov.provider}_id"] = prov.user_id
64
+ render json: data, status: 200
63
65
  else
64
66
  render json: {}, status: 400
65
67
  end
@@ -1,3 +1,3 @@
1
1
  module ApiUserAuth
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
@@ -341,6 +341,35 @@ module ApiUserAuth
341
341
 
342
342
  end
343
343
 
344
- context
344
+ context 'Add provider' do
345
+ let(:auth_user) do
346
+ AuthUser.create_by_params(email: 'user@mail.com', password: '123456')
347
+ end
348
+
349
+ it 'Valid' do
350
+ allow(ApiUserAuth::Providers::Google).to(
351
+ receive_message_chain(:get_user).and_return(
352
+ email: 'user@mail.com', name: 'User Name', provider: 'google',
353
+ id: '102030'
354
+ )
355
+ )
356
+
357
+ token = auth_user.auth_tokens.last
358
+ request.headers['HTTP_AUTHORIZATION'] = "Bearer #{token}"
359
+ expect(AuthUser.count).to eq(1)
360
+ expect(auth_user.provider_tokens.count).to eq(0)
361
+
362
+ params = {
363
+ provider: 'google', token: 'token'
364
+ }
365
+
366
+ post :add_provider, params: params
367
+
368
+ expect(auth_user.provider_tokens.count).to eq(1)
369
+
370
+ expect(resp_json[:google_id]).to eq('102030')
371
+ end
372
+
373
+ end
345
374
  end
346
375
  end
Binary file
Binary file