multi_auth 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,13 +1,17 @@
1
1
  MultiAuth
2
2
  =========
3
3
 
4
- This engine provides basic login functionality for your Rails applications.
4
+ This engine provides basic signup/login functionality for your Rails applications.
5
5
 
6
6
  Install
7
7
  =======
8
8
 
9
9
  $ sudo gem install okkez-multi_auth
10
10
 
11
+ or
12
+
13
+ $ sudo gem install multi_auth
14
+
11
15
  Setup
12
16
  =====
13
17
 
@@ -15,14 +19,29 @@ Setup
15
19
 
16
20
  Create migrations for open_id_authentication.
17
21
 
18
- $ rake multi_auth:copy:all
22
+ $ ruby script/generate multi_auth_migration create_multi_auth_tables
19
23
 
20
- Copy migrations, stylesheets and images from multi_auth plugin.
24
+ Create migrations for multi_auth.
21
25
 
22
26
  $ rake db:migrate
23
27
 
24
28
  You must have a model 'User'. User model has any columns which you want to add.
25
29
 
30
+ Ex.
31
+
32
+ class User < ActiveRecord::Base
33
+ multi_auth
34
+ end
35
+
36
+ You can use MultiAuthHelper, see below.
37
+
38
+ Ex.
39
+
40
+ module ApplicationHelper
41
+ include MultiAuthHelper
42
+ end
43
+
44
+
26
45
  Customize
27
46
  =========
28
47
 
@@ -45,7 +45,7 @@ class Signup::EmailController < ApplicationController
45
45
  def create
46
46
  @signup_form = EditFormClass.new(session[:signup_form])
47
47
 
48
- @user = User.new
48
+ @user = MultiAuth.user_model_class.new
49
49
  @credential = @user.email_credentials.build
50
50
  @credential.attributes = @signup_form.to_email_credential_hash
51
51
 
@@ -42,7 +42,7 @@ class Signup::OpenIdController < ApplicationController
42
42
  def create
43
43
  @identity_url = session[:identity_url]
44
44
 
45
- @user = User.new
45
+ @user = MultiAuth.user_model_class.new
46
46
  @credential = @user.open_id_credentials.build
47
47
  @credential.identity_url = @identity_url
48
48
 
@@ -12,13 +12,14 @@
12
12
  #
13
13
 
14
14
  # ユーザ
15
- class User < ActiveRecord::Base
15
+ class DummyUser < ActiveRecord::Base
16
+ untranslate_all
17
+ set_table_name 'users'
16
18
  NicknameMaximumLength = 40
17
19
  TokenLength = 20
18
20
  TokenPattern = TokenUtil.create_token_regexp(TokenLength)
19
21
 
20
- has_many :open_id_credentials
21
- has_many :email_credentials
22
+ multi_auth
22
23
 
23
24
  validates_presence_of :user_token
24
25
  validates_length_of :nickname, :maximum => NicknameMaximumLength, :allow_nil => true
@@ -22,7 +22,7 @@ class EmailCredential < ActiveRecord::Base
22
22
  HashedPasswordPattern = /\A([0-9a-f]{8}):([0-9a-f]{64})\z/
23
23
  MaximumRecordsPerUser = 10
24
24
 
25
- belongs_to :user
25
+ belongs_to :user, :class_name => MultiAuth.user_model, :foreign_key => 'user_id'
26
26
 
27
27
  validates_presence_of :email
28
28
  validates_presence_of :activation_token
@@ -15,7 +15,7 @@
15
15
  class OpenIdCredential < ActiveRecord::Base
16
16
  MaximumRecordsPerUser = 10
17
17
 
18
- belongs_to :user
18
+ belongs_to :user, :class_name => MultiAuth.user_model, :foreign_key => 'user_id'
19
19
 
20
20
  validates_presence_of :identity_url
21
21
  validates_length_of :identity_url, :maximum => 200, :allow_nil => true
@@ -0,0 +1,5 @@
1
+ Description:
2
+ Sets up MultiAuth in your Rails project.
3
+
4
+ Examples:
5
+ `./script/generate mutli_auth`
@@ -0,0 +1,12 @@
1
+
2
+ class MultiAuthMigrationGenerator < Rails::Generator::NamedBase
3
+ def initialize(runtime_args, runtime_options = { })
4
+ super
5
+ end
6
+
7
+ def manifest
8
+ record do |m|
9
+ m.migration_template('migration.rb', 'db/migrate')
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*-
2
+ class <%= class_name %> < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :open_id_credentials do |t|
5
+ t.datetime :created_at, :null => false
6
+ t.integer :user_id, :null => false
7
+ t.string :identity_url, :null => false, :limit => 200
8
+ t.datetime :loggedin_at, :null => true
9
+ end
10
+
11
+ add_index :open_id_credentials, :user_id
12
+ add_index :open_id_credentials, :identity_url, :unique => true
13
+
14
+ create_table :email_credentials do |t|
15
+ t.datetime :created_at, :null => false
16
+ t.string :activation_token, :null => false, :limit => 40
17
+ t.integer :user_id, :null => false
18
+ t.string :email, :null => false, :limit => 200
19
+ t.string :hashed_password, :null => false, :limit => 8 + 1 + 64
20
+ t.datetime :activated_at, :null => true
21
+ t.datetime :loggedin_at, :null => true
22
+ end
23
+
24
+ add_index :email_credentials, :created_at
25
+ add_index :email_credentials, :activation_token, :unique => true
26
+ add_index :email_credentials, :user_id
27
+ add_index :email_credentials, :email, :unique => true
28
+ add_index :email_credentials, :activated_at
29
+ end
30
+
31
+ def self.down
32
+ drop_table :open_id_credentials
33
+ drop_table :email_credentials
34
+ end
35
+ end
@@ -0,0 +1,13 @@
1
+
2
+ class MultiAuthStyleSheetGenerator < Rails::Generator::Base
3
+ def initialize(runtime_args, runtime_options = { })
4
+ super
5
+ end
6
+
7
+ def manifest
8
+ record do |m|
9
+ m.directory('public/stylesheets')
10
+ m.file('style.css', 'public/stylesheets/multi_auth.css')
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,502 @@
1
+
2
+ /* generic */
3
+
4
+ *
5
+ {
6
+ margin: 0;
7
+ padding: 0;
8
+ }
9
+
10
+ body
11
+ {
12
+ width: 100%;
13
+ background-color: #F0F0F0;
14
+ }
15
+
16
+ a
17
+ {
18
+ color: #0066CC;
19
+ text-decoration: none;
20
+ }
21
+
22
+ a:hover
23
+ {
24
+ text-decoration: underline;
25
+ }
26
+
27
+ a img
28
+ {
29
+ border-width: 0;
30
+ }
31
+
32
+ /* head */
33
+
34
+ #head-outer
35
+ {
36
+ position: relative;
37
+ width: 100%;
38
+ min-width: 700px;
39
+ height: 120px;
40
+ background-color: #000000;
41
+ background-image: url(/images/logo-back.png);
42
+ background-repeat: repeat-x;
43
+ }
44
+
45
+ #head-inner
46
+ {
47
+ }
48
+
49
+ #head-logo
50
+ {
51
+ position: relative;
52
+ width: 350px;
53
+ }
54
+ #head-logo img
55
+ {
56
+ display: block;
57
+ }
58
+
59
+ #head-navi
60
+ {
61
+ position: absolute;
62
+ top: 95px;
63
+ right: 10px;
64
+ font-size: 13px;
65
+ line-height: 20px;
66
+ color: #CCCCCC;
67
+ }
68
+ #head-navi a
69
+ {
70
+ color: #99CCFF;
71
+ }
72
+
73
+ #head-ad
74
+ {
75
+ position: absolute;
76
+ width: 470px;
77
+ height: 62px;
78
+ top: 25px;
79
+ right: 20px;
80
+ }
81
+
82
+ /* body */
83
+
84
+ #body-outer-with-background,
85
+ #body-outer-without-background
86
+ {
87
+ position: relative;
88
+ width: 100%;
89
+ min-width: 700px;
90
+ }
91
+
92
+ #body-outer-with-background
93
+ {
94
+ background-image: url(../images/side-column-back.png);
95
+ background-repeat: repeat-y;
96
+ background-position: right;
97
+ }
98
+
99
+ #body-inner
100
+ {
101
+ }
102
+
103
+ #content-outer
104
+ {
105
+ }
106
+
107
+ #content-inner
108
+ {
109
+ padding: 10px;
110
+ }
111
+
112
+ #content-column-outer
113
+ {
114
+ margin: 0px 200px 0px 0px;
115
+ }
116
+
117
+ #content-column-inner
118
+ {
119
+ padding: 10px;
120
+ }
121
+
122
+ #side-column-outer
123
+ {
124
+ width: 200px;
125
+ min-height: 400px;
126
+ }
127
+
128
+ #side-column-inner
129
+ {
130
+ padding: 10px;
131
+ }
132
+
133
+ /* foot */
134
+
135
+ #foot-outer
136
+ {
137
+ width: 100%;
138
+ min-width: 700px;
139
+ border-width: 1px 0px 0px 0px;
140
+ border-style: solid;
141
+ border-color: #D0D0D0;
142
+ }
143
+
144
+ #foot-inner
145
+ {
146
+ padding: 20px;
147
+ }
148
+
149
+ #foot-powerd
150
+ {
151
+ float: right;
152
+ font-size: 90%;
153
+ font-weight: bold;
154
+ color: #999999;
155
+ }
156
+ #foot-powerd a
157
+ {
158
+ color: #333333;
159
+ }
160
+
161
+ #foot-github
162
+ {
163
+ font-size: 95%;
164
+ }
165
+
166
+ #foot-services
167
+ {
168
+ font-size: 90%;
169
+ color: #999999;
170
+ }
171
+ #foot-services a
172
+ {
173
+ color: #333333;
174
+ }
175
+
176
+ /* topic path */
177
+
178
+ #topic-path
179
+ {
180
+ padding: 0.1em 0.4em;
181
+ background-color: #E0E0E0;
182
+ color: #999999;
183
+ font-size: 90%;
184
+ }
185
+
186
+ #topic-path a
187
+ {
188
+ }
189
+
190
+ #topic-path em
191
+ {
192
+ color: #666666;
193
+ font-weight: bold;
194
+ font-style: normal;
195
+ }
196
+
197
+ /* for debug */
198
+
199
+ div.debug
200
+ {
201
+ margin-top: 1em;
202
+ background-color: #FFF0F0;
203
+ }
204
+
205
+ /* table.list */
206
+
207
+ table.list
208
+ {
209
+ border-collapse: collapse;
210
+ }
211
+
212
+ table.list thead tr th
213
+ {
214
+ padding: 0.4em;
215
+ border-width: 1px;
216
+ border-style: solid;
217
+ border-color: #F0F0F0;
218
+ color: #CCCCCC;
219
+ background-color: #333333;
220
+ }
221
+
222
+ table.list tbody tr
223
+ {
224
+ border-width: 1px;
225
+ border-style: solid;
226
+ border-color: #F0F0F0;
227
+ }
228
+
229
+ table.list tbody tr td
230
+ {
231
+ padding: 0.2em 0.4em;
232
+ border-width: 0;
233
+ }
234
+
235
+ table.list tbody tr.even td
236
+ {
237
+ background-color: #E0E0E0;
238
+ }
239
+
240
+ table.list tbody tr.odd td
241
+ {
242
+ background-color: #D0D0D0;
243
+ }
244
+
245
+ /* table.energies */
246
+
247
+ table.energies img
248
+ {
249
+ vertical-align: text-top;
250
+ }
251
+
252
+ table.energies thead tr th
253
+ {
254
+ font-size: 70%;
255
+ }
256
+
257
+ table.energies tbody tr td
258
+ {
259
+ font-size: 80%;
260
+ }
261
+
262
+ table.energies tfoot td
263
+ {
264
+ color: #999999;
265
+ text-align: right;
266
+ }
267
+
268
+ /* table.events */
269
+
270
+ table.events img
271
+ {
272
+ vertical-align: text-top;
273
+ }
274
+
275
+ table.events thead tr th
276
+ {
277
+ font-size: 70%;
278
+ }
279
+
280
+ table.events tbody tr td
281
+ {
282
+ font-size: 80%;
283
+ }
284
+
285
+ table.events tfoot td
286
+ {
287
+ color: #999999;
288
+ text-align: right;
289
+ }
290
+
291
+ /* battery */
292
+
293
+ div.battery-cell
294
+ {
295
+ margin: 0;
296
+ padding: 4px 7px 4px 5px;
297
+ width: 100px;
298
+ height: 13px;
299
+ background-image: url(/images/battery/cell.png);
300
+ background-repeat: no-repeat;
301
+ }
302
+
303
+ div.battery-level
304
+ {
305
+ margin: 0;
306
+ padding: 0;
307
+ width: 100px;
308
+ height: 13px;
309
+ }
310
+
311
+ div.battery-high,
312
+ div.battery-middle,
313
+ div.battery-low,
314
+ div.battery-empty
315
+ {
316
+ margin: 0;
317
+ padding: 0;
318
+ height: 13px;
319
+ background-repeat: repeat-x;
320
+ }
321
+
322
+ div.battery-high
323
+ {
324
+ background-image: url(/images/battery/level-green.png);
325
+ }
326
+
327
+ div.battery-middle
328
+ {
329
+ background-image: url(/images/battery/level-orange.png);
330
+ }
331
+
332
+ div.battery-low
333
+ {
334
+ background-image: url(/images/battery/level-yellow.png);
335
+ }
336
+
337
+ div.battery-empty
338
+ {
339
+ background-image: url(/images/battery/level-red.png);
340
+ }
341
+
342
+ /* signup-progress */
343
+ /* FIXME: 別ファイルに分離 */
344
+
345
+ ol#email-signup-progress
346
+ {
347
+ }
348
+
349
+ ol#email-signup-progress li
350
+ {
351
+ display: inline;
352
+ border-style: solid;
353
+ border-width: 1px;
354
+ border-color: black;
355
+ }
356
+
357
+ ol#email-signup-progress li.active
358
+ {
359
+ font-weight: bold;
360
+ }
361
+
362
+ ol#email-signup-progress li.inactive
363
+ {
364
+ font-weight: normal;
365
+ }
366
+
367
+ #dialog
368
+ {
369
+ margin: 100px auto;
370
+ padding: 15px;
371
+ width: 500px;
372
+ border-width: 1px;
373
+ border-style: solid;
374
+ border-color: #CCCCCC;
375
+ }
376
+ #dialog h1
377
+ {
378
+ margin: 0 0 0.4em 0;
379
+ color: #666666;
380
+ font-size: 130%;
381
+ font-weight: bold;
382
+ }
383
+ .message
384
+ {
385
+ color: #999999;
386
+ font-size: 90%;
387
+ }
388
+
389
+ h1
390
+ {
391
+ background-image: url(/images/h1-back.png);
392
+ background-repeat: repeat-x;
393
+ background-position: left center;
394
+ }
395
+ h1 span
396
+ {
397
+ padding-right: 0.2em;
398
+ background-color: #F0F0F0;
399
+ }
400
+
401
+ h2
402
+ {
403
+ background-image: url(/images/h1-back.png);
404
+ background-repeat: repeat-x;
405
+ background-position: left center;
406
+ }
407
+ h2 span
408
+ {
409
+ padding-right: 0.2em;
410
+ background-color: #F0F0F0;
411
+ }
412
+
413
+ /* side-column */
414
+
415
+ #side-column-inner h1
416
+ {
417
+ margin-bottom: 8px;
418
+ color: #666666;
419
+ font-size: 16px;
420
+ font-weight: bold;
421
+ }
422
+
423
+ #side-column-inner hr
424
+ {
425
+ height: 1px;
426
+ margin: 8px 0px;
427
+ border: none;
428
+ background-color: #CCCCCC;
429
+ }
430
+
431
+ #signup-link
432
+ {
433
+ font-size: 22px;
434
+ font-weight: bold;
435
+ text-align: center;
436
+ }
437
+ #signup-free
438
+ {
439
+ margin-bottom: 10px;
440
+ font-size: 12px;
441
+ text-align: center;
442
+ color: #990000;
443
+ }
444
+
445
+ #openid-sites
446
+ {
447
+ font-size: 12px;
448
+ line-height: 18px;
449
+ }
450
+ #openid-sites img
451
+ {
452
+ vertical-align: text-bottom;
453
+ }
454
+
455
+ #side-column-inner form input.openid,
456
+ #side-column-inner form input.openid-with-desc,
457
+ #side-column-inner form input.email,
458
+ #side-column-inner form input.email-with-desc,
459
+ #side-column-inner form input.password,
460
+ #side-column-inner form input.password-with-desc
461
+ {
462
+ width: 160px; /* width:200 - (padding:20 + padding:18 + border:2)*/
463
+ height: 20px;
464
+ margin-bottom: 4px;
465
+ padding-left: 18px;
466
+ border-width: 1px;
467
+ border-style: solid;
468
+ border-color: #666666;
469
+ background-repeat: no-repeat;
470
+ background-position: 1px;
471
+ }
472
+
473
+ #side-column-inner form input.openid
474
+ {
475
+ background-image: url(/images/icons/openid.png);
476
+ }
477
+
478
+ #side-column-inner form input.openid-with-desc
479
+ {
480
+ background-image: url(/images/icons/openid-with-desc.png);
481
+ }
482
+
483
+ #side-column-inner form input.email
484
+ {
485
+ background-image: url(/images/icons/fam/email.png);
486
+ }
487
+
488
+ #side-column-inner form input.email-with-desc
489
+ {
490
+ background-image: url(/images/icons/fam/email-with-desc.png);
491
+ }
492
+
493
+ #side-column-inner form input.password
494
+ {
495
+ background-image: url(/images/icons/fam/key.png);
496
+ }
497
+
498
+ #side-column-inner form input.password-with-desc
499
+ {
500
+ background-image: url(/images/icons/fam/key-with-desc.png);
501
+ }
502
+
@@ -0,0 +1,50 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module MultiAuth
4
+ module ActionController
5
+ module ClassMethods
6
+ def verify_method_post(options = {})
7
+ verify({
8
+ :method => :post,
9
+ :render => {:text => "Method Not Allowed", :status => 405},
10
+ }.merge(options))
11
+ end
12
+ end
13
+ module InstanceMethods
14
+ private
15
+
16
+ def authentication(user_id = session[:user_id])
17
+ @login_user = MultiAuth.user_model_class.find_by_id(user_id)
18
+ return true
19
+ end
20
+
21
+ def authentication_required
22
+ if @login_user
23
+ return true
24
+ else
25
+ set_error("ログインが必要です。")
26
+ redirect_to(root_path)
27
+ return false
28
+ end
29
+ end
30
+
31
+ def set_notice(message)
32
+ flash[:notice] = @flash_notice = message
33
+ flash[:error] = @flash_error = nil
34
+ end
35
+
36
+ def set_error(message)
37
+ flash[:notice] = @flash_notice = nil
38
+ flash[:error] = @flash_error = message
39
+ end
40
+
41
+ def set_error_now(message)
42
+ flash.now[:notice] = @flash_notice = nil
43
+ flash.now[:error] = @flash_error = message
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ ActionController::Base.__send__(:extend, MultiAuth::ActionController::ClassMethods)
50
+ ActionController::Base.__send__(:include, MultiAuth::ActionController::InstanceMethods)
@@ -0,0 +1,16 @@
1
+
2
+ module MultiAuth
3
+ module ActiveRecord
4
+ module ClassMethods
5
+ def multi_auth(options = { })
6
+ class_eval do
7
+ has_many :open_id_credentials, :foreign_key => 'user_id', :dependent => :destroy
8
+ has_many :email_credentials, :foreign_key => 'user_id', :dependent => :destroy
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ ActiveRecord::Base.__send__(:extend, MultiAuth::ActiveRecord::ClassMethods)
16
+
data/lib/multi_auth.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- class MultiAuth
3
+ module MultiAuth
4
4
 
5
5
  class << self
6
6
  attr_accessor_with_default :application_name, 'app'
@@ -9,56 +9,13 @@ class MultiAuth
9
9
  def setup
10
10
  yield self
11
11
  end
12
-
13
- def self.user_model_class
14
- @user_model.constantize
15
- end
16
12
  end
17
13
 
18
- module ClassMethods
19
- def verify_method_post(options = {})
20
- verify({
21
- :method => :post,
22
- :render => {:text => "Method Not Allowed", :status => 405},
23
- }.merge(options))
24
- end
25
- end
26
-
27
- module InstanceMethods
28
-
29
- private
30
-
31
- def authentication(user_id = session[:user_id])
32
- @login_user = User.find_by_id(user_id)
33
- return true
34
- end
35
-
36
- def authentication_required
37
- if @login_user
38
- return true
39
- else
40
- set_error("ログインが必要です。")
41
- redirect_to(root_path)
42
- return false
43
- end
44
- end
45
-
46
- def set_notice(message)
47
- flash[:notice] = @flash_notice = message
48
- flash[:error] = @flash_error = nil
49
- end
50
-
51
- def set_error(message)
52
- flash[:notice] = @flash_notice = nil
53
- flash[:error] = @flash_error = message
54
- end
55
-
56
- def set_error_now(message)
57
- flash.now[:notice] = @flash_notice = nil
58
- flash.now[:error] = @flash_error = message
59
- end
14
+ def self.user_model_class
15
+ user_model.constantize
60
16
  end
61
17
  end
62
18
 
63
- ActionController::Base.__send__(:extend, MultiAuth::ClassMethods)
64
- ActionController::Base.__send__(:include, MultiAuth::InstanceMethods)
19
+ require 'multi_auth/action_controller'
20
+ require 'multi_auth/active_record'
21
+
@@ -153,7 +153,7 @@ class Signup::EmailControllerTest < ActionController::TestCase
153
153
  @request.session[:signup_form] = @signup_form.attributes
154
154
 
155
155
  assert_difference("EmailCredential.count", +1) {
156
- assert_difference("User.count", +1) {
156
+ assert_difference("#{MultiAuth.user_model}.count", +1) {
157
157
  post :create
158
158
  }
159
159
  }
data/test/test_helper.rb CHANGED
@@ -41,6 +41,7 @@ class ActiveSupport::TestCase
41
41
  #
42
42
  # Note: You'll currently still have to declare fixtures explicitly in integration tests
43
43
  # -- they do not yet inherit this setting
44
+ set_fixture_class({ :users => DummyUser })
44
45
  fixtures :all
45
46
 
46
47
  # Add more helper methods to be used by all tests here...
@@ -79,4 +80,5 @@ class ActiveSupport::TestCase
79
80
  assert_nil(assigns(:flash_notice))
80
81
  assert_not_nil(assigns(:flash_error))
81
82
  end
83
+
82
84
  end
@@ -2,9 +2,9 @@
2
2
 
3
3
  require 'test_helper'
4
4
 
5
- class UserTest < ActiveSupport::TestCase
5
+ class DummyUserTest < ActiveSupport::TestCase
6
6
  def setup
7
- @klass = User
7
+ @klass = DummyUser
8
8
  @basic = @klass.new(
9
9
  :user_token => "0" * @klass::TokenLength,
10
10
  :nickname => "nickname")
@@ -128,13 +128,13 @@ class NoticeFormatterTest < ActiveSupport::TestCase
128
128
 
129
129
  test "format_part_of_user" do
130
130
  expected = {
131
- "user:token" => "0" * User::TokenLength,
132
- "user:token:json" => '"' + "0" * User::TokenLength + '"',
131
+ "user:token" => "0" * MultiAuth.user_model_class::TokenLength,
132
+ "user:token:json" => '"' + "0" * MultiAuth.user_model_class::TokenLength + '"',
133
133
  "user:nickname" => "nickname",
134
134
  "user:nickname:json" => '"nickname"',
135
135
  }
136
- user = User.new(
137
- :user_token => "0" * User::TokenLength,
136
+ user = MultiAuth.user_model_class.new(
137
+ :user_token => "0" * MultiAuth.user_model_class::TokenLength,
138
138
  :nickname => "nickname")
139
139
  assert_equal(expected, @module.format_part_of_user(user))
140
140
  end
@@ -146,7 +146,7 @@ class NoticeFormatterTest < ActiveSupport::TestCase
146
146
  "user:nickname" => "-",
147
147
  "user:nickname:json" => "null",
148
148
  }
149
- assert_equal(expected, @module.format_part_of_user(User.new))
149
+ assert_equal(expected, @module.format_part_of_user(MultiAuth.user_model_class.new))
150
150
  assert_equal(expected, @module.format_part_of_user(nil))
151
151
  end
152
152
 
@@ -19,19 +19,19 @@ class TokenUtilTest < ActiveSupport::TestCase
19
19
  end
20
20
 
21
21
  test "create_unique_token" do
22
- assert_match(/\A[0-9a-f]{10}\z/, @mod.create_unique_token(User, :user_token, 10))
23
- assert_match(/\A[0-9a-f]{20}\z/, @mod.create_unique_token(User, :user_token, 20))
24
- assert_match(/\A[0-9a-f]{30}\z/, @mod.create_unique_token(User, :user_token, 30))
22
+ assert_match(/\A[0-9a-f]{10}\z/, @mod.create_unique_token(MultiAuth.user_model_class, :user_token, 10))
23
+ assert_match(/\A[0-9a-f]{20}\z/, @mod.create_unique_token(MultiAuth.user_model_class, :user_token, 20))
24
+ assert_match(/\A[0-9a-f]{30}\z/, @mod.create_unique_token(MultiAuth.user_model_class, :user_token, 30))
25
25
 
26
26
  srand(0)
27
27
  assert_not_equal(
28
- @mod.create_unique_token(User, :user_token, 20),
29
- @mod.create_unique_token(User, :user_token, 20))
28
+ @mod.create_unique_token(MultiAuth.user_model_class, :user_token, 20),
29
+ @mod.create_unique_token(MultiAuth.user_model_class, :user_token, 20))
30
30
  end
31
31
 
32
32
  test "create_unique_token, conflict" do
33
33
  [
34
- [User, :user_token],
34
+ [MultiAuth.user_model_class, :user_token],
35
35
  ].each { |klass, column|
36
36
  exist_token = klass.first[column]
37
37
  unique_token = "0" * exist_token.size
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - okkez
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-08 00:00:00 +09:00
12
+ date: 2009-12-11 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -52,9 +52,9 @@ files:
52
52
  - app/controllers/credentials_controller.rb
53
53
  - app/controllers/signup/email_controller.rb
54
54
  - app/controllers/signup/open_id_controller.rb
55
+ - app/models/dummy_user.rb
55
56
  - app/models/email_credential_edit_form.rb
56
57
  - app/models/open_id_login_form.rb
57
- - app/models/user.rb
58
58
  - app/models/activation_mailer.rb
59
59
  - app/models/email_credential.rb
60
60
  - app/models/session.rb
@@ -105,6 +105,8 @@ files:
105
105
  - lib/multi_auth_helper.rb
106
106
  - lib/token_util.rb
107
107
  - lib/open_id_authentication/result.rb
108
+ - lib/multi_auth/active_record.rb
109
+ - lib/multi_auth/action_controller.rb
108
110
  - public/favicon.ico
109
111
  - public/422.html
110
112
  - public/503.html
@@ -153,6 +155,11 @@ files:
153
155
  - public/images/h1-back.png
154
156
  - public/robots.txt
155
157
  - rails/init.rb
158
+ - generators/multi_auth_style_sheet/multi_auth_style_sheet_generator.rb
159
+ - generators/multi_auth_style_sheet/templates/style.css
160
+ - generators/multi_auth_migration/multi_auth_migration_generator.rb
161
+ - generators/multi_auth_migration/USAGE
162
+ - generators/multi_auth_migration/templates/migration.rb
156
163
  - test/unit/token_util_test.rb
157
164
  - test/unit/open_id_login_form_test.rb
158
165
  - test/unit/notice_formatter_test.rb
@@ -170,7 +177,7 @@ files:
170
177
  - test/unit/helpers/auth_helper_test.rb
171
178
  - test/unit/action_mailer_util_test.rb
172
179
  - test/unit/open_id_credential_test.rb
173
- - test/unit/user_test.rb
180
+ - test/unit/dummy_user_test.rb
174
181
  - test/unit/activation_mailer_test.rb
175
182
  - test/unit/session_test.rb
176
183
  - test/unit/email_credential_test.rb