omniauth-identity 2.0.0 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +61 -1
- data/CODE_OF_CONDUCT.md +133 -0
- data/LICENSE +2 -1
- data/README.md +256 -0
- data/lib/omniauth-identity.rb +2 -0
- data/lib/omniauth-identity/version.rb +3 -1
- data/lib/omniauth/identity.rb +4 -1
- data/lib/omniauth/identity/model.rb +13 -11
- data/lib/omniauth/identity/models/active_record.rb +4 -1
- data/lib/omniauth/identity/models/couch_potato.rb +3 -4
- data/lib/omniauth/identity/models/mongoid.rb +3 -7
- data/lib/omniauth/identity/models/no_brainer.rb +30 -0
- data/lib/omniauth/identity/models/sequel.rb +37 -0
- data/lib/omniauth/identity/secure_password.rb +4 -4
- data/lib/omniauth/strategies/identity.rb +92 -39
- data/spec/omniauth/identity/model_spec.rb +36 -33
- data/spec/omniauth/identity/models/active_record_spec.rb +23 -9
- data/spec/omniauth/identity/models/couch_potato_spec.rb +13 -8
- data/spec/omniauth/identity/models/mongoid_spec.rb +16 -11
- data/spec/omniauth/identity/models/no_brainer_spec.rb +17 -0
- data/spec/omniauth/identity/models/sequel_spec.rb +23 -0
- data/spec/omniauth/identity/secure_password_spec.rb +10 -8
- data/spec/omniauth/strategies/identity_spec.rb +174 -61
- data/spec/spec_helper.rb +17 -8
- metadata +60 -97
- data/.gitignore +0 -6
- data/.rspec +0 -3
- data/Gemfile +0 -13
- data/Guardfile +0 -10
- data/README.markdown +0 -204
- data/Rakefile +0 -9
- data/lib/omniauth/identity/models/data_mapper.rb +0 -32
- data/omniauth-identity.gemspec +0 -32
- data/spec/omniauth/identity/models/data_mapper_spec.rb +0 -24
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
|
2
|
-
require 'bundler'
|
3
|
-
Bundler.setup :default, :development, :test
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
|
6
|
-
require 'simplecov'
|
7
|
-
SimpleCov.start
|
3
|
+
ruby_version = Gem::Version.new(RUBY_VERSION)
|
4
|
+
require 'simplecov' if ruby_version >= Gem::Version.new('2.7') && RUBY_ENGINE == 'ruby'
|
8
5
|
|
9
6
|
require 'rack/test'
|
10
7
|
require 'mongoid-rspec'
|
11
|
-
require '
|
8
|
+
require 'sqlite3'
|
9
|
+
require 'sequel'
|
10
|
+
require 'anonymous_active_record'
|
11
|
+
require 'byebug' if RUBY_ENGINE == 'ruby'
|
12
12
|
|
13
13
|
# This gem
|
14
14
|
require 'omniauth/identity'
|
@@ -16,5 +16,14 @@ require 'omniauth/identity'
|
|
16
16
|
RSpec.configure do |config|
|
17
17
|
config.include Rack::Test::Methods
|
18
18
|
config.include Mongoid::Matchers, type: :model
|
19
|
-
end
|
20
19
|
|
20
|
+
# Enable flags like --only-failures and --next-failure
|
21
|
+
config.example_status_persistence_file_path = '.rspec_status'
|
22
|
+
|
23
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
24
|
+
config.disable_monkey_patching!
|
25
|
+
|
26
|
+
config.expect_with :rspec do |c|
|
27
|
+
c.syntax = :expect
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-identity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Peter Boling
|
7
8
|
- Andrew Roberts
|
8
9
|
- Michael Bleigh
|
9
|
-
autorequire:
|
10
|
-
bindir:
|
10
|
+
autorequire:
|
11
|
+
bindir: exe
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2021-02-14 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
+
name: bcrypt
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
17
18
|
requirements:
|
18
19
|
- - ">="
|
@@ -26,7 +27,7 @@ dependencies:
|
|
26
27
|
- !ruby/object:Gem::Version
|
27
28
|
version: '0'
|
28
29
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
30
|
+
name: omniauth
|
30
31
|
requirement: !ruby/object:Gem::Requirement
|
31
32
|
requirements:
|
32
33
|
- - ">="
|
@@ -40,189 +41,150 @@ dependencies:
|
|
40
41
|
- !ruby/object:Gem::Version
|
41
42
|
version: '0'
|
42
43
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
44
|
+
name: anonymous_active_record
|
44
45
|
requirement: !ruby/object:Gem::Requirement
|
45
46
|
requirements:
|
46
|
-
- - "
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '0'
|
49
|
-
type: :development
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
47
|
+
- - "~>"
|
54
48
|
- !ruby/object:Gem::Version
|
55
|
-
version: '0'
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: simplecov
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
49
|
+
version: '1.0'
|
60
50
|
- - ">="
|
61
51
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
52
|
+
version: 1.0.8
|
63
53
|
type: :development
|
64
54
|
prerelease: false
|
65
55
|
version_requirements: !ruby/object:Gem::Requirement
|
66
56
|
requirements:
|
67
|
-
- - "
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: rack-test
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - ">="
|
57
|
+
- - "~>"
|
75
58
|
- !ruby/object:Gem::Version
|
76
|
-
version: '0'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
59
|
+
version: '1.0'
|
81
60
|
- - ">="
|
82
61
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
62
|
+
version: 1.0.8
|
84
63
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - ">="
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: '0'
|
91
|
-
type: :development
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - ">="
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '0'
|
98
|
-
- !ruby/object:Gem::Dependency
|
99
|
-
name: rspec
|
64
|
+
name: mongoid
|
100
65
|
requirement: !ruby/object:Gem::Requirement
|
101
66
|
requirements:
|
102
67
|
- - "~>"
|
103
68
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
69
|
+
version: '7'
|
105
70
|
type: :development
|
106
71
|
prerelease: false
|
107
72
|
version_requirements: !ruby/object:Gem::Requirement
|
108
73
|
requirements:
|
109
74
|
- - "~>"
|
110
75
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
76
|
+
version: '7'
|
112
77
|
- !ruby/object:Gem::Dependency
|
113
|
-
name:
|
78
|
+
name: nobrainer
|
114
79
|
requirement: !ruby/object:Gem::Requirement
|
115
80
|
requirements:
|
116
|
-
- - "
|
81
|
+
- - "~>"
|
117
82
|
- !ruby/object:Gem::Version
|
118
83
|
version: '0'
|
119
84
|
type: :development
|
120
85
|
prerelease: false
|
121
86
|
version_requirements: !ruby/object:Gem::Requirement
|
122
87
|
requirements:
|
123
|
-
- - "
|
88
|
+
- - "~>"
|
124
89
|
- !ruby/object:Gem::Version
|
125
90
|
version: '0'
|
126
91
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
92
|
+
name: rack-test
|
128
93
|
requirement: !ruby/object:Gem::Requirement
|
129
94
|
requirements:
|
130
|
-
- - "
|
95
|
+
- - "~>"
|
131
96
|
- !ruby/object:Gem::Version
|
132
|
-
version: '
|
97
|
+
version: '1'
|
133
98
|
type: :development
|
134
99
|
prerelease: false
|
135
100
|
version_requirements: !ruby/object:Gem::Requirement
|
136
101
|
requirements:
|
137
|
-
- - "
|
102
|
+
- - "~>"
|
138
103
|
- !ruby/object:Gem::Version
|
139
|
-
version: '
|
104
|
+
version: '1'
|
140
105
|
- !ruby/object:Gem::Dependency
|
141
|
-
name:
|
106
|
+
name: rake
|
142
107
|
requirement: !ruby/object:Gem::Requirement
|
143
108
|
requirements:
|
144
|
-
- - "
|
109
|
+
- - "~>"
|
145
110
|
- !ruby/object:Gem::Version
|
146
|
-
version: '
|
111
|
+
version: '13'
|
147
112
|
type: :development
|
148
113
|
prerelease: false
|
149
114
|
version_requirements: !ruby/object:Gem::Requirement
|
150
115
|
requirements:
|
151
|
-
- - "
|
116
|
+
- - "~>"
|
152
117
|
- !ruby/object:Gem::Version
|
153
|
-
version: '
|
118
|
+
version: '13'
|
154
119
|
- !ruby/object:Gem::Dependency
|
155
|
-
name:
|
120
|
+
name: rspec
|
156
121
|
requirement: !ruby/object:Gem::Requirement
|
157
122
|
requirements:
|
158
|
-
- - "
|
123
|
+
- - "~>"
|
159
124
|
- !ruby/object:Gem::Version
|
160
|
-
version: '
|
125
|
+
version: '3'
|
161
126
|
type: :development
|
162
127
|
prerelease: false
|
163
128
|
version_requirements: !ruby/object:Gem::Requirement
|
164
129
|
requirements:
|
165
|
-
- - "
|
130
|
+
- - "~>"
|
166
131
|
- !ruby/object:Gem::Version
|
167
|
-
version: '
|
132
|
+
version: '3'
|
168
133
|
- !ruby/object:Gem::Dependency
|
169
|
-
name:
|
134
|
+
name: sequel
|
170
135
|
requirement: !ruby/object:Gem::Requirement
|
171
136
|
requirements:
|
172
|
-
- - "
|
137
|
+
- - "~>"
|
173
138
|
- !ruby/object:Gem::Version
|
174
|
-
version: '
|
139
|
+
version: '5'
|
175
140
|
type: :development
|
176
141
|
prerelease: false
|
177
142
|
version_requirements: !ruby/object:Gem::Requirement
|
178
143
|
requirements:
|
179
|
-
- - "
|
144
|
+
- - "~>"
|
180
145
|
- !ruby/object:Gem::Version
|
181
|
-
version: '
|
146
|
+
version: '5'
|
182
147
|
- !ruby/object:Gem::Dependency
|
183
|
-
name:
|
148
|
+
name: sqlite3
|
184
149
|
requirement: !ruby/object:Gem::Requirement
|
185
150
|
requirements:
|
186
|
-
- - "
|
151
|
+
- - "~>"
|
187
152
|
- !ruby/object:Gem::Version
|
188
|
-
version: '
|
153
|
+
version: '1.4'
|
189
154
|
type: :development
|
190
155
|
prerelease: false
|
191
156
|
version_requirements: !ruby/object:Gem::Requirement
|
192
157
|
requirements:
|
193
|
-
- - "
|
158
|
+
- - "~>"
|
194
159
|
- !ruby/object:Gem::Version
|
195
|
-
version: '
|
160
|
+
version: '1.4'
|
196
161
|
description: Internal authentication handlers for OmniAuth.
|
197
|
-
email:
|
162
|
+
email:
|
198
163
|
executables: []
|
199
164
|
extensions: []
|
200
165
|
extra_rdoc_files: []
|
201
166
|
files:
|
202
|
-
- ".gitignore"
|
203
|
-
- ".rspec"
|
204
167
|
- CHANGELOG.md
|
205
|
-
-
|
206
|
-
- Guardfile
|
168
|
+
- CODE_OF_CONDUCT.md
|
207
169
|
- LICENSE
|
208
|
-
- README.
|
209
|
-
- Rakefile
|
170
|
+
- README.md
|
210
171
|
- lib/omniauth-identity.rb
|
211
172
|
- lib/omniauth-identity/version.rb
|
212
173
|
- lib/omniauth/identity.rb
|
213
174
|
- lib/omniauth/identity/model.rb
|
214
175
|
- lib/omniauth/identity/models/active_record.rb
|
215
176
|
- lib/omniauth/identity/models/couch_potato.rb
|
216
|
-
- lib/omniauth/identity/models/data_mapper.rb
|
217
177
|
- lib/omniauth/identity/models/mongoid.rb
|
178
|
+
- lib/omniauth/identity/models/no_brainer.rb
|
179
|
+
- lib/omniauth/identity/models/sequel.rb
|
218
180
|
- lib/omniauth/identity/secure_password.rb
|
219
181
|
- lib/omniauth/strategies/identity.rb
|
220
|
-
- omniauth-identity.gemspec
|
221
182
|
- spec/omniauth/identity/model_spec.rb
|
222
183
|
- spec/omniauth/identity/models/active_record_spec.rb
|
223
184
|
- spec/omniauth/identity/models/couch_potato_spec.rb
|
224
|
-
- spec/omniauth/identity/models/data_mapper_spec.rb
|
225
185
|
- spec/omniauth/identity/models/mongoid_spec.rb
|
186
|
+
- spec/omniauth/identity/models/no_brainer_spec.rb
|
187
|
+
- spec/omniauth/identity/models/sequel_spec.rb
|
226
188
|
- spec/omniauth/identity/secure_password_spec.rb
|
227
189
|
- spec/omniauth/strategies/identity_spec.rb
|
228
190
|
- spec/spec_helper.rb
|
@@ -230,32 +192,33 @@ homepage: http://github.com/omniauth/omniauth-identity
|
|
230
192
|
licenses:
|
231
193
|
- MIT
|
232
194
|
metadata: {}
|
233
|
-
post_install_message:
|
234
|
-
rdoc_options:
|
195
|
+
post_install_message:
|
196
|
+
rdoc_options:
|
197
|
+
- "--charset=UTF-8"
|
235
198
|
require_paths:
|
236
199
|
- lib
|
237
200
|
required_ruby_version: !ruby/object:Gem::Requirement
|
238
201
|
requirements:
|
239
202
|
- - ">="
|
240
203
|
- !ruby/object:Gem::Version
|
241
|
-
version: '
|
204
|
+
version: '2.4'
|
242
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
206
|
requirements:
|
244
207
|
- - ">="
|
245
208
|
- !ruby/object:Gem::Version
|
246
209
|
version: 1.3.6
|
247
210
|
requirements: []
|
248
|
-
|
249
|
-
|
250
|
-
signing_key:
|
211
|
+
rubygems_version: 3.2.3
|
212
|
+
signing_key:
|
251
213
|
specification_version: 4
|
252
214
|
summary: Internal authentication handlers for OmniAuth.
|
253
215
|
test_files:
|
254
216
|
- spec/omniauth/identity/model_spec.rb
|
255
217
|
- spec/omniauth/identity/models/active_record_spec.rb
|
256
218
|
- spec/omniauth/identity/models/couch_potato_spec.rb
|
257
|
-
- spec/omniauth/identity/models/data_mapper_spec.rb
|
258
219
|
- spec/omniauth/identity/models/mongoid_spec.rb
|
220
|
+
- spec/omniauth/identity/models/no_brainer_spec.rb
|
221
|
+
- spec/omniauth/identity/models/sequel_spec.rb
|
259
222
|
- spec/omniauth/identity/secure_password_spec.rb
|
260
223
|
- spec/omniauth/strategies/identity_spec.rb
|
261
224
|
- spec/spec_helper.rb
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/Gemfile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
|
-
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
group :development, :test do
|
7
|
-
gem 'mongoid-rspec', github: 'mongoid/mongoid-rspec'
|
8
|
-
gem 'guard'
|
9
|
-
gem 'guard-rspec'
|
10
|
-
gem 'guard-bundler'
|
11
|
-
gem 'growl'
|
12
|
-
gem 'rb-fsevent'
|
13
|
-
end
|
data/Guardfile
DELETED
data/README.markdown
DELETED
@@ -1,204 +0,0 @@
|
|
1
|
-
# OmniAuth Identity
|
2
|
-
|
3
|
-
The OmniAuth Identity gem provides a way for applications to utilize a
|
4
|
-
traditional login/password based authentication system without the need
|
5
|
-
to give up the simple authentication flow provided by OmniAuth. Identity
|
6
|
-
is designed on purpose to be as featureless as possible: it provides the
|
7
|
-
basic construct for user management and then gets out of the way.
|
8
|
-
|
9
|
-
## Usage
|
10
|
-
|
11
|
-
This can be a bit hard to understand the first time. Luckily, Ryan Bates made
|
12
|
-
a [Railscast](http://railscasts.com/episodes/304-omniauth-identity) about it!
|
13
|
-
|
14
|
-
You use `omniauth-identity` just like you would any other OmniAuth provider: as a
|
15
|
-
Rack middleware. The basic setup for a email/password authentication would
|
16
|
-
look something like this:
|
17
|
-
|
18
|
-
```ruby
|
19
|
-
use OmniAuth::Builder do
|
20
|
-
provider :identity, :fields => [:email]
|
21
|
-
end
|
22
|
-
```
|
23
|
-
|
24
|
-
Next, you need to create a model (called `Identity by default`) that will be
|
25
|
-
able to persist the information provided by the user. Luckily for you, there
|
26
|
-
are pre-built models for popular ORMs that make this dead simple.
|
27
|
-
|
28
|
-
**Note:** OmniAuth Identity is different from many other user authentication
|
29
|
-
systems in that it is *not* built to store authentication information in your primary
|
30
|
-
`User` model. Instead, the `Identity` model should be **associated** with your
|
31
|
-
`User` model giving you maximum flexibility to include other authentication
|
32
|
-
strategies such as Facebook, Twitter, etc.
|
33
|
-
|
34
|
-
### ActiveRecord
|
35
|
-
|
36
|
-
Just subclass `OmniAuth::Identity::Models::ActiveRecord` and provide fields
|
37
|
-
in the database for all of the fields you are using.
|
38
|
-
|
39
|
-
```ruby
|
40
|
-
class Identity < OmniAuth::Identity::Models::ActiveRecord
|
41
|
-
# Add whatever you like!
|
42
|
-
end
|
43
|
-
```
|
44
|
-
|
45
|
-
### Mongoid
|
46
|
-
|
47
|
-
Include the `OmniAuth::Identity::Models::Mongoid` mixin and specify
|
48
|
-
fields that you will need.
|
49
|
-
|
50
|
-
```ruby
|
51
|
-
class Identity
|
52
|
-
include Mongoid::Document
|
53
|
-
include OmniAuth::Identity::Models::Mongoid
|
54
|
-
|
55
|
-
field :email, type: String
|
56
|
-
field :name, type: String
|
57
|
-
field :password_digest, type: String
|
58
|
-
end
|
59
|
-
```
|
60
|
-
|
61
|
-
### MongoMapper
|
62
|
-
|
63
|
-
Unfortunately MongoMapper is **not supported** in `omniauth-identity` from >= v2.0 as a result of it
|
64
|
-
not being maintained for several years.
|
65
|
-
|
66
|
-
It wasn't possible to include Mongoid *and* MongoMapper due to incompatible gem version
|
67
|
-
requirements. Therefore precedence was given to Mongoid as it is significantly more
|
68
|
-
popular and actively maintained.
|
69
|
-
|
70
|
-
### DataMapper
|
71
|
-
|
72
|
-
Include the `OmniAuth::Identity::Models::DataMapper` mixin and specify
|
73
|
-
fields that you will need.
|
74
|
-
|
75
|
-
```ruby
|
76
|
-
class Identity
|
77
|
-
include DataMapper::Resource
|
78
|
-
include OmniAuth::Identity::Models::DataMapper
|
79
|
-
|
80
|
-
property :id, Serial
|
81
|
-
property :email, String
|
82
|
-
property :password_digest, Text
|
83
|
-
|
84
|
-
attr_accessor :password_confirmation
|
85
|
-
|
86
|
-
end
|
87
|
-
```
|
88
|
-
|
89
|
-
### CouchPotato
|
90
|
-
|
91
|
-
Include the `OmniAuth::Identity::Models::CouchPotatoModule` mixin and specify fields that you will need.
|
92
|
-
|
93
|
-
```ruby
|
94
|
-
class Identity
|
95
|
-
include CouchPotato::Persistence
|
96
|
-
include OmniAuth::Identity::Models::CouchPotatoModule
|
97
|
-
|
98
|
-
property :email
|
99
|
-
property :password_digest
|
100
|
-
|
101
|
-
def self.where search_hash
|
102
|
-
CouchPotato.database.view Identity.by_email(:key => search_hash)
|
103
|
-
end
|
104
|
-
|
105
|
-
view :by_email, :key => :email
|
106
|
-
end
|
107
|
-
```
|
108
|
-
|
109
|
-
Once you've got an Identity persistence model and the strategy up and
|
110
|
-
running, you can point users to `/auth/identity` and it will request
|
111
|
-
that they log in or give them the opportunity to sign up for an account.
|
112
|
-
Once they have authenticated with their identity, OmniAuth will call
|
113
|
-
through to `/auth/identity/callback` with the same kinds of information
|
114
|
-
it would had the user authenticated through an external provider.
|
115
|
-
Simple!
|
116
|
-
|
117
|
-
## Custom Auth Model
|
118
|
-
|
119
|
-
To use a class other than the default, specify the <tt>:model</tt> option to a
|
120
|
-
different class.
|
121
|
-
|
122
|
-
```ruby
|
123
|
-
use OmniAuth::Builder do
|
124
|
-
provider :identity, :fields => [:email], :model => MyCustomClass
|
125
|
-
end
|
126
|
-
```
|
127
|
-
|
128
|
-
## Customizing Registration Failure
|
129
|
-
|
130
|
-
To use your own custom registration form, create a form that POSTs to
|
131
|
-
'/auth/identity/register' with 'password', 'password_confirmation', and your
|
132
|
-
other fields.
|
133
|
-
|
134
|
-
```erb
|
135
|
-
<%= form_tag '/auth/identity/register' do |f| %>
|
136
|
-
<h1>Create an Account</h1>
|
137
|
-
<%= text_field_tag :email %>
|
138
|
-
<%= password_field_tag :password %>
|
139
|
-
<%= password_field_tag :password_confirmation %>
|
140
|
-
<%= submit_tag %>
|
141
|
-
<% end %>
|
142
|
-
```
|
143
|
-
|
144
|
-
Beware not to nest your form parameters within a namespace. This strategy
|
145
|
-
looks for the form parameters at the top level of the post params. If you are
|
146
|
-
using [simple\_form](https://github.com/plataformatec/simple_form), then you
|
147
|
-
can avoid the params nesting by specifying <tt>:input_html</tt>.
|
148
|
-
|
149
|
-
```erb
|
150
|
-
<%= simple_form_for @identity, :url => '/auth/identity/register' do |f| %>
|
151
|
-
<h1>Create an Account</h1>
|
152
|
-
<%# specify :input_html to avoid params nesting %>
|
153
|
-
<%= f.input :email, :input_html => {:name => 'email'} %>
|
154
|
-
<%= f.input :password, :as => 'password', :input_html => {:name => 'password'} %>
|
155
|
-
<%= f.input :password_confirmation, :label => "Confirm Password", :as => 'password', :input_html => {:name => 'password_confirmation'} %>
|
156
|
-
<button type='submit'>Sign Up</button>
|
157
|
-
<% end %>
|
158
|
-
```
|
159
|
-
|
160
|
-
Next you'll need to let OmniAuth know what action to call when a registration
|
161
|
-
fails. In your OmniAuth configuration, specify any valid rack endpoint in the
|
162
|
-
<tt>:on_failed_registration</tt> option.
|
163
|
-
|
164
|
-
```ruby
|
165
|
-
use OmniAuth::Builder do
|
166
|
-
provider :identity,
|
167
|
-
:fields => [:email],
|
168
|
-
:on_failed_registration => UsersController.action(:new)
|
169
|
-
end
|
170
|
-
```
|
171
|
-
|
172
|
-
For more information on rack endpoints, check out [this
|
173
|
-
introduction](http://library.edgecase.com/Rails/2011/01/04/rails-routing-and-rack-endpoints.html)
|
174
|
-
and
|
175
|
-
[ActionController::Metal](http://rubydoc.info/docs/rails/ActionController/Metal)
|
176
|
-
|
177
|
-
## Customizing Locate Conditions
|
178
|
-
|
179
|
-
You can customize the way that matching records are found when authenticating.
|
180
|
-
For example, for a site with multiple domains, you may wish to scope the search
|
181
|
-
within a particular subdomain. To do so, add :locate_conditions to your config.
|
182
|
-
The default value is:
|
183
|
-
|
184
|
-
```ruby
|
185
|
-
:locate_conditions => lambda { |req| { model.auth_key => req['auth_key']} }
|
186
|
-
```
|
187
|
-
|
188
|
-
locate_conditions takes a Proc object, and must return a hash. The resulting hash is used
|
189
|
-
as a parameter in the locate method for your ORM. The proc is evaluated in the
|
190
|
-
callback context, and has access to the Identity model (using `model`) and receives the request
|
191
|
-
object as a parameter. Note that model.auth_key defaults to 'email', but is also configurable.
|
192
|
-
|
193
|
-
Note: Be careful when customizing locate_conditions. The best way to modify the conditions is
|
194
|
-
to copy the default value, and then add to the hash. Removing the default condition will almost
|
195
|
-
always break things!
|
196
|
-
|
197
|
-
## License
|
198
|
-
|
199
|
-
MIT License. See LICENSE for details.
|
200
|
-
|
201
|
-
## Copyright
|
202
|
-
|
203
|
-
Copyright (c) 2020- Andrew Roberts, and Jellybooks Ltd.
|
204
|
-
Copyright (c) 2010-2015 Michael Bleigh, and Intridea, Inc.
|