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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba3c14ea3b6ac4344d27136de619c3bf44435afa
4
- data.tar.gz: 1d5f6e2f0b26795d0832e0476a7c503979f1b173
3
+ metadata.gz: 6e34b92c66fb533a85adbef20c6fe180a9bd5d64
4
+ data.tar.gz: d9ce8df6b826e7008159a3b8d2483f1a0dd9fe3f
5
5
  SHA512:
6
- metadata.gz: 182a6062796accb539ec47572906ca097b4ebca42c6e3ed2e1446f948d83f93268e9586a1960c9d857d7bfa3cab7af43082e9b024e6df81f14d303c1c6369ea3
7
- data.tar.gz: 50e41310eb3e0b1a29240ac3f35e37935bf67c537ca3a1688590ac39186add293a1433defc54d555800a8727efb2b910e537a2b456c3b663f919d1ae310e982d
6
+ metadata.gz: 9f1c95ae2407295002184e996d2a67fbf22e76a4dd8e83ecfea20bcc3f907127f7e09fd5e4f0bf8fe74169d42abb948e53fcc1349744cf358174167be46272fe
7
+ data.tar.gz: 550269f5e0b4bf115e105acb04b408ba2d75144cccb4897f7849784e270fc882d3df5d015e2ec759e5938c1166815376f42e8715fb52dbab35a45f35aba2a11d
data/.DS_Store CHANGED
Binary file
@@ -1,56 +1,58 @@
1
- class Agilib::TokensController < Devise::SessionsController
2
- skip_before_filter :verify_authenticity_token
3
- respond_to :json
4
-
5
- def create
6
- login = params[:email]
7
- password = params[:password]
8
-
9
- if request.format != :json
10
- render :status=>406, :json => { :message => "The request must be json" }
11
- return
12
- end
13
-
14
- if login.nil? or password.nil?
15
- render :status=>400, :json=>{ :message => "The request must contain the user login and password." }
16
- return
17
- end
18
-
19
- if User.respond_to? "find_by"
20
- @user = User.find_by(email: login.downcase)
21
- elsif User.respond_to? "find_by_email"
22
- @user = User.find_by_email(login.downcase)
23
- end
24
-
25
- if @user.nil?
26
- render :status=>401, :json=>{:message=>"Invalid login or passoword."}
27
- return
28
- end
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
- @user.ensure_authentication_token
31
- @user.save!
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
- end
40
-
41
- def destroy
42
- @user=User.find_by_authentication_token(params[:id])
43
- if @user.nil?
44
- render :status=>404, :json=>{:message=>"Invalid token."}
45
- else
46
- @user.authentication_token = ""
47
- @user.save!
48
-
49
- sign_out @user
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
- render :status => 200, :json=>{:user=> @user, :token=>params[:id]}
52
-
54
+ end
53
55
  end
54
- end
55
56
 
57
+ end
56
58
  end
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,6 @@
1
+ module Agilib
2
+ class Engine < ::Rails::Engine
3
+ config.autoload_paths += Dir["#{config.root}/lib/**/"]
4
+ config.autoload_paths += Dir["#{config.root}/app/**/"]
5
+ end
6
+ end
@@ -3,7 +3,7 @@ module Agilib
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
5
  PATCH = 0
6
- BUILD = 'beta3'
6
+ BUILD = 'beta4'
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
9
9
  end
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.beta3
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