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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad72c48358e56a514640ca816c94f481a98010d2
4
- data.tar.gz: 11b0f26e81d7e0393733c328edfb1f0e47a61006
3
+ metadata.gz: 2ff493b67a4701d70bbc56086e9b27b87c77811b
4
+ data.tar.gz: 1e57af80ab57100aed35f73f3a1dfdfdd6434339
5
5
  SHA512:
6
- metadata.gz: 8757dcbf0bd42fb6962e27a5910ac2eaae48739ae95c598b258c6a4504c4a7c821d6d04156047a40a2dcb179e35c078e1f61c5794926783df31a744f17149938
7
- data.tar.gz: 04dfbd8c33d303beb95639568f0ee8885403710c9448836182c695e2c0b4686dfc84268f9602d0dc585ef5061b603d5f3262633f1f6f90d5cee751385a58be8e
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
@@ -0,0 +1,6 @@
1
+ Rails.application.routes.draw do
2
+ namespace :devise_multiple_token_auth do
3
+ post "auth/login", to: "token_authentication#login", defaults: { format: 'json'}
4
+ delete "auth/logout", to: "token_authentication#logout", defaults: { format: 'json'}
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module DeviseMultipleTokenAuth
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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
- - db/migrate/20150828180247_create_devise_multiple_token_auth_devices.rb
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,9 +0,0 @@
1
- class CreateDeviseMultipleTokenAuthDevices < ActiveRecord::Migration
2
- def change
3
- create_table :devise_multiple_token_auth_devices do |t|
4
- t.belongs_to :user, index: true
5
- t.string :auth_token
6
- t.timestamps null: false
7
- end
8
- end
9
- end
@@ -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