devise_multiple_token_auth 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/devise_multiple_token_auth/token_authentication_controller.rb +24 -0
- data/config/routes.rb +6 -0
- data/lib/devise_multiple_token_auth/version.rb +1 -1
- metadata +3 -3
- data/db/migrate/20150828180247_create_devise_multiple_token_auth_devices.rb +0 -9
- data/db/migrate/20150828182850_add_push_notification_fields_to_devices.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ff493b67a4701d70bbc56086e9b27b87c77811b
|
4
|
+
data.tar.gz: 1e57af80ab57100aed35f73f3a1dfdfdd6434339
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65006e27f33f226c9af873f279d942edd417dbd9f9864ae5742f87926604c06a9bca5c6e2b67dd648f6a1700dadf56658c8e6297138f362dfde4d98c4ba13571
|
7
|
+
data.tar.gz: 9589d7ae29e52d20ba9693b5a7a6f5ff9d05ef55464c31aa9ba1c538f313e3fcd8aa35d26c9633fe0e2c69ed15d966103d1057fffdba4711db0c2b07d5b44c58
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class DeviseMultipleTokenAuth::TokenAuthenticationController < ApplicationController
|
2
|
+
|
3
|
+
before_filter :authenticate_token_user!
|
4
|
+
skip_filter :authenticate_token_user!, only: [:login]
|
5
|
+
|
6
|
+
respond_to :json
|
7
|
+
def login
|
8
|
+
email = params[:email] || params[:username]
|
9
|
+
password = params[:password]
|
10
|
+
user = User.find_by(email: email)
|
11
|
+
if user.present? && user.valid_password?(params[:password])
|
12
|
+
device = user.create_device
|
13
|
+
render json: {auth_token: device.auth_token}, status: :ok
|
14
|
+
else
|
15
|
+
render json: {error: 'Invalid credentials', code: '401'}, status: :unauthorized
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def logout
|
20
|
+
@device.destroy if @device
|
21
|
+
head :no_content
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/config/routes.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_multiple_token_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Juncker
|
@@ -63,12 +63,12 @@ extra_rdoc_files: []
|
|
63
63
|
files:
|
64
64
|
- MIT-LICENSE
|
65
65
|
- Rakefile
|
66
|
+
- app/controllers/devise_multiple_token_auth/token_authentication_controller.rb
|
66
67
|
- app/models/devise_multiple_token_auth/device.rb
|
67
68
|
- app/models/devise_multiple_token_auth/device/android.rb
|
68
69
|
- app/models/devise_multiple_token_auth/device/ios.rb
|
69
70
|
- app/models/devise_multiple_token_auth/device/windowsphone.rb
|
70
|
-
-
|
71
|
-
- db/migrate/20150828182850_add_push_notification_fields_to_devices.rb
|
71
|
+
- config/routes.rb
|
72
72
|
- lib/devise_multiple_token_auth.rb
|
73
73
|
- lib/devise_multiple_token_auth/action_controller/base.rb
|
74
74
|
- lib/devise_multiple_token_auth/active_record/base.rb
|
@@ -1,7 +0,0 @@
|
|
1
|
-
class AddPushNotificationFieldsToDevices < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
add_column :devise_multiple_token_auth_devices, :platform, :string
|
4
|
-
add_column :devise_multiple_token_auth_devices, :push_token, :string
|
5
|
-
add_column :devise_multiple_token_auth_devices, :expires_at, :datetime
|
6
|
-
end
|
7
|
-
end
|