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 +4 -4
- data/app/controllers/api_user_auth/auth_controller.rb +4 -2
- data/lib/api_user_auth/version.rb +1 -1
- data/spec/controllers/api_user_auth/auth_controller_spec.rb +30 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +1255 -56
- data/spec/dummy/log/test.log +60722 -1469
- metadata +45 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c361db01eddc3c4e3679474cdedd7df1e800cb22f4053b6625f6db9cad41e6c
|
4
|
+
data.tar.gz: e47b8d653ff59fe59ac7f4c2af18fd4695fae1987ffc2d720faadb7422e684a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
@@ -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
|