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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e246db4f5e60c64425fc46be892629169f5562b488995b9dae8baa5af7f0f4d
4
- data.tar.gz: 9b80ec381be2ede4d05a5efbdc5e37b90a7f99237e6a8c7faf2dbbde1ccc1df9
3
+ metadata.gz: d6aea234e2c37d4fee91e09c9e3dc9e14b70a2f13a4773469e9d80432b28fd40
4
+ data.tar.gz: 250d64c10dbcda5e92666727e1a0be0766955ea080f628d39a619be21aca805b
5
5
  SHA512:
6
- metadata.gz: cc1ff51a2a5e8ce550391c0345d0616ee2be9cf8ee67483727a66c6ccbf8475955d1e99050e8d25d3235f5422a3156f95f03fb01c52c5ca989bb34efb3b3a7af
7
- data.tar.gz: b35e88869eecfed877e8d29b68015bd2b9b6e42336fa814c27b7ac7bf2984ac2ef43817aec0e62d2193cf10408f697e1c3861ac10299f426b726a290dc272bc4
6
+ metadata.gz: 7ac5e15556b99e862ea1ef7275c671b30abf6e557c595f8ecae8364141f8a8e09ecd6bd62dd2a86c009cd8009bfa9c6a6b5ece58b9df4545b9ab3cfa73e72557
7
+ data.tar.gz: 2dfe9a53ef07272d9cfc435b87d6ad772be6cb27ca54ef0e7f28bae9ee898b42e9aa5916ea90a7e849a80cb56810cdea6b708df830fc2e6fc2a96fc05af981f2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cow_auth (0.6.1)
4
+ cow_auth (0.6.2)
5
5
  activesupport (~> 5.1)
6
6
  scrypt (~> 3.0)
7
7
 
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: { sid: user.sid, auth_token: user.auth_token }, status: :ok
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
@@ -1,3 +1,3 @@
1
1
  module CowAuth
2
- VERSION = '0.6.1'
2
+ VERSION = '0.6.2'
3
3
  end
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.1
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-08 00:00:00.000000000 Z
11
+ date: 2018-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler