agilib 0.1.0.beta3 → 0.1.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/app/controllers/agilib/tokens_controller.rb +50 -48
- data/lib/.DS_Store +0 -0
- data/lib/agilib/engine.rb +6 -0
- data/lib/agilib/version.rb +1 -1
- data/lib/agilib.rb +4 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e34b92c66fb533a85adbef20c6fe180a9bd5d64
|
4
|
+
data.tar.gz: d9ce8df6b826e7008159a3b8d2483f1a0dd9fe3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f1c95ae2407295002184e996d2a67fbf22e76a4dd8e83ecfea20bcc3f907127f7e09fd5e4f0bf8fe74169d42abb948e53fcc1349744cf358174167be46272fe
|
7
|
+
data.tar.gz: 550269f5e0b4bf115e105acb04b408ba2d75144cccb4897f7849784e270fc882d3df5d015e2ec759e5938c1166815376f42e8715fb52dbab35a45f35aba2a11d
|
data/.DS_Store
CHANGED
Binary file
|
@@ -1,56 +1,58 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
1
|
+
module Agilib
|
2
|
+
class TokensController < Devise::SessionsController
|
3
|
+
skip_before_filter :verify_authenticity_token
|
4
|
+
respond_to :json
|
5
|
+
|
6
|
+
def create
|
7
|
+
login = params[:email]
|
8
|
+
password = params[:password]
|
9
|
+
|
10
|
+
if request.format != :json
|
11
|
+
render :status=>406, :json => { :message => "The request must be json" }
|
12
|
+
return
|
13
|
+
end
|
14
|
+
|
15
|
+
if login.nil? or password.nil?
|
16
|
+
render :status=>400, :json=>{ :message => "The request must contain the user login and password." }
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
if User.respond_to? "find_by"
|
21
|
+
@user = User.find_by(email: login.downcase)
|
22
|
+
elsif User.respond_to? "find_by_email"
|
23
|
+
@user = User.find_by_email(login.downcase)
|
24
|
+
end
|
25
|
+
|
26
|
+
if @user.nil?
|
27
|
+
render :status=>401, :json=>{:message=>"Invalid login or passoword."}
|
28
|
+
return
|
29
|
+
end
|
30
|
+
|
31
|
+
@user.ensure_authentication_token
|
32
|
+
@user.save!
|
29
33
|
|
30
|
-
|
31
|
-
|
34
|
+
if not @user.valid_password?(password)
|
35
|
+
render :status=> 401, :json=>{:message=>"Invalid login or passoword."}
|
36
|
+
else
|
37
|
+
render :status=>200, :json=>{:user=> @user, :token => @user.authentication_token}
|
38
|
+
end
|
32
39
|
|
33
|
-
if not @user.valid_password?(password)
|
34
|
-
render :status=> 401, :json=>{:message=>"Invalid login or passoword."}
|
35
|
-
else
|
36
|
-
render :status=>200, :json=>{:user=> @user, :token => @user.authentication_token}
|
37
40
|
end
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
def destroy
|
43
|
+
@user=User.find_by_authentication_token(params[:id])
|
44
|
+
if @user.nil?
|
45
|
+
render :status=>404, :json=>{:message=>"Invalid token."}
|
46
|
+
else
|
47
|
+
@user.authentication_token = ""
|
48
|
+
@user.save!
|
49
|
+
|
50
|
+
sign_out @user
|
51
|
+
|
52
|
+
render :status => 200, :json=>{:user=> @user, :token=>params[:id]}
|
50
53
|
|
51
|
-
|
52
|
-
|
54
|
+
end
|
53
55
|
end
|
54
|
-
end
|
55
56
|
|
57
|
+
end
|
56
58
|
end
|
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/agilib/version.rb
CHANGED
data/lib/agilib.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
1
3
|
module Agilib
|
2
4
|
|
3
5
|
def self.rails4?
|
@@ -14,5 +16,7 @@ module Agilib
|
|
14
16
|
|
15
17
|
end
|
16
18
|
|
19
|
+
require 'agilib/version'
|
20
|
+
require 'agilib/engine'
|
17
21
|
require 'agilib/token_authentication/token_authentication'
|
18
22
|
require 'agilib/token_authentication/token_authentication_handler'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agilib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcos Junior
|
@@ -131,8 +131,10 @@ files:
|
|
131
131
|
- app/controllers/.DS_Store
|
132
132
|
- app/controllers/agilib/tokens_controller.rb
|
133
133
|
- bin/agilib
|
134
|
+
- lib/.DS_Store
|
134
135
|
- lib/agilib.rb
|
135
136
|
- lib/agilib/cli.rb
|
137
|
+
- lib/agilib/engine.rb
|
136
138
|
- lib/agilib/token_authentication/token_authentication.rb
|
137
139
|
- lib/agilib/token_authentication/token_authentication_handler.rb
|
138
140
|
- lib/agilib/version.rb
|