cow_auth 0.6.1 → 0.6.2
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/Gemfile.lock +1 -1
- data/README.md +29 -1
- data/lib/cow_auth/token_auth/session_endpoints.rb +10 -4
- data/lib/cow_auth/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6aea234e2c37d4fee91e09c9e3dc9e14b70a2f13a4773469e9d80432b28fd40
|
4
|
+
data.tar.gz: 250d64c10dbcda5e92666727e1a0be0766955ea080f628d39a619be21aca805b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ac5e15556b99e862ea1ef7275c671b30abf6e557c595f8ecae8364141f8a8e09ecd6bd62dd2a86c009cd8009bfa9c6a6b5ece58b9df4545b9ab3cfa73e72557
|
7
|
+
data.tar.gz: 2dfe9a53ef07272d9cfc435b87d6ad772be6cb27ca54ef0e7f28bae9ee898b42e9aa5916ea90a7e849a80cb56810cdea6b708df830fc2e6fc2a96fc05af981f2
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -99,12 +99,40 @@ Add the following private method to the ApplicationController (assuming User is
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
#### Sessions Controller Example
|
102
|
+
#### Sessions Controller HTML Example
|
103
|
+
|
104
|
+
The `sign_in_success_path` and `sign_out_success_path` methods need to be defined for redirecting after successful sign-in and sign-out.
|
105
|
+
|
106
|
+
class SessionsController < ApplicationController
|
107
|
+
include CowAuth::SessionAuth::SessionEndpoints
|
108
|
+
|
109
|
+
skip_before_action :authenticate_user, only: [:new, :create]
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def sign_in_success_path
|
114
|
+
return root_url
|
115
|
+
end
|
116
|
+
|
117
|
+
def sign_out_success_path
|
118
|
+
return sign_in_url
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
#### Sessions Controller JSON Example
|
123
|
+
|
124
|
+
The `sign_in_success_response_payload` method can optionally be overridden to customize the response payload for a successful sign-in.
|
103
125
|
|
104
126
|
class Api::V1::SessionsController < ApplicationController
|
105
127
|
include CowAuth::TokenAuth::SessionEndpoints
|
106
128
|
|
107
129
|
skip_before_action :authenticate_user, only: [:create]
|
130
|
+
|
131
|
+
protected
|
132
|
+
|
133
|
+
def sign_in_success_response_payload
|
134
|
+
return { uuid: @user.uuid, sid: @user.sid, auth_token: @user.auth_token }
|
135
|
+
end
|
108
136
|
end
|
109
137
|
|
110
138
|
### Token Authentication
|
@@ -6,10 +6,10 @@ module CowAuth
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
def create
|
9
|
-
user = authentication_class.find_by(email: params[:email])
|
10
|
-
if user.try(:authenticate_with_password, params[:password])
|
11
|
-
user.create_auth_token
|
12
|
-
render json:
|
9
|
+
@user = authentication_class.find_by(email: params[:email])
|
10
|
+
if @user.try(:authenticate_with_password, params[:password])
|
11
|
+
@user.create_auth_token
|
12
|
+
render json: self.sign_in_success_response_payload, status: :ok
|
13
13
|
else
|
14
14
|
raise CowAuth::NotAuthenticatedError.new('Invalid user credentials.')
|
15
15
|
end
|
@@ -22,6 +22,12 @@ module CowAuth
|
|
22
22
|
raise CowAuth::NotAuthenticatedError.new('Could not sign user out.')
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def sign_in_success_response_payload
|
29
|
+
return { sid: @user.sid, auth_token: @user.auth_token }
|
30
|
+
end
|
25
31
|
end
|
26
32
|
end
|
27
33
|
end
|
data/lib/cow_auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cow_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mickey Cowden
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|