multi_auth 0.0.4 → 0.0.5

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.
Files changed (58) hide show
  1. data/README +15 -1
  2. data/app/controllers/application_controller.rb +1 -0
  3. data/app/controllers/auth/email_controller.rb +1 -1
  4. data/app/controllers/auth/open_id_controller.rb +3 -3
  5. data/app/controllers/credentials/email_controller.rb +10 -9
  6. data/app/controllers/credentials/open_id_controller.rb +7 -1
  7. data/app/controllers/signup/email_controller.rb +5 -5
  8. data/app/controllers/signup/open_id_controller.rb +3 -1
  9. data/app/models/activation_mailer.rb +6 -6
  10. data/app/models/email_credential.rb +5 -0
  11. data/app/models/open_id_credential.rb +5 -0
  12. data/app/models/session.rb +4 -0
  13. data/app/views/activation_mailer/complete_for_credential.erb +1 -1
  14. data/app/views/activation_mailer/complete_for_notice.erb +1 -1
  15. data/app/views/activation_mailer/complete_for_signup.erb +1 -1
  16. data/app/views/activation_mailer/request_for_credential.erb +5 -5
  17. data/app/views/activation_mailer/request_for_notice.erb +5 -5
  18. data/app/views/activation_mailer/request_for_signup.erb +5 -5
  19. data/app/views/auth/email/index.html.erb +3 -3
  20. data/app/views/auth/index.html.erb +5 -5
  21. data/app/views/auth/logged_in.html.erb +5 -3
  22. data/app/views/auth/logged_out.html.erb +5 -3
  23. data/app/views/auth/open_id/index.html.erb +3 -3
  24. data/app/views/credentials/email/activated.html.erb +4 -1
  25. data/app/views/credentials/email/activation.html.erb +3 -3
  26. data/app/views/credentials/email/created.html.erb +4 -4
  27. data/app/views/credentials/email/delete.html.erb +7 -4
  28. data/app/views/credentials/email/edit_password.html.erb +4 -4
  29. data/app/views/credentials/email/new.html.erb +2 -2
  30. data/app/views/credentials/index.html.erb +16 -16
  31. data/app/views/credentials/open_id/delete.html.erb +6 -3
  32. data/app/views/credentials/open_id/new.html.erb +2 -2
  33. data/app/views/signup/email/_progress.html.erb +14 -14
  34. data/app/views/signup/email/activated.html.erb +4 -4
  35. data/app/views/signup/email/activation.html.erb +8 -8
  36. data/app/views/signup/email/created.html.erb +6 -4
  37. data/app/views/signup/email/index.html.erb +3 -3
  38. data/app/views/signup/email/validated.html.erb +5 -5
  39. data/app/views/signup/index.html.erb +22 -9
  40. data/app/views/signup/open_id/authenticated.html.erb +3 -3
  41. data/app/views/signup/open_id/created.html.erb +3 -3
  42. data/app/views/signup/open_id/index.html.erb +3 -3
  43. data/config/cucumber.yml +7 -0
  44. data/config/database.yml +4 -1
  45. data/config/environment.rb +1 -1
  46. data/config/routes.rb +21 -20
  47. data/db/test.sqlite3 +0 -0
  48. data/lib/multi_auth/action_controller.rb +32 -1
  49. data/lib/multi_auth.rb +5 -0
  50. data/lib/open_id_authentication/result.rb +5 -5
  51. data/locale/ja/LC_MESSAGES/multi_auth.mo +0 -0
  52. data/po/ja/multi_auth.po +639 -0
  53. data/po/multi_auth.pot +637 -0
  54. data/test/functional/auth/open_id_controller_test.rb +1 -1
  55. data/test/functional/auth_controller_test.rb +10 -7
  56. data/test/functional/credentials_controller_test.rb +9 -0
  57. data/test/unit/activation_mailer_test.rb +2 -2
  58. metadata +7 -2
@@ -1,5 +1,5 @@
1
1
 
2
- <%- @title = "メール認証情報の追加" -%>
2
+ <%- @title = p_("MultiAuth", "Add email authentication credential") -%>
3
3
 
4
4
  <h1><%=h @title %></h1>
5
5
 
@@ -22,7 +22,7 @@
22
22
  </td>
23
23
  </tr>
24
24
  </table>
25
- <div><%= submit_tag("追加") %></div>
25
+ <div><%= submit_tag(p_("MultiAuth", "Add")) %></div>
26
26
  <%- } -%>
27
27
 
28
28
  <%- unless production? -%>
@@ -1,13 +1,13 @@
1
1
 
2
- <%- @title = "ログイン設定" -%>
2
+ <%- @title = p_("MultiAuth", "Login setting") -%>
3
3
 
4
- <h2>OpenID認証</h2>
4
+ <h2><%=h p_("MultiAuth", "OpenID authentication") %></h2>
5
5
 
6
6
  <table class="list">
7
7
  <thead>
8
8
  <tr>
9
- <th>登録日</th>
10
- <th>最終ログイン日時</th>
9
+ <th><%=h s_("OpenIdCredential|Activated on") %></th>
10
+ <th><%=h s_("OpenIdCredential|Loggedin at") %></th>
11
11
  <th>OpenID</th>
12
12
  <th>&nbsp;</th>
13
13
  </tr>
@@ -16,7 +16,7 @@
16
16
  <tr>
17
17
  <td colspan="4">
18
18
  <%- can_add_open_id_credential = (@open_id_credentials.size < OpenIdCredential::MaximumRecordsPerUser) -%>
19
- <%= link_to_if(can_add_open_id_credential, add_icon + h(" OpenID認証を追加する"), :controller => "credentials/open_id", :action => "new") %>
19
+ <%= link_to_if(can_add_open_id_credential, add_icon + h(" " + p_("MultiAuth", "Add OpenID authentication")), :controller => "credentials/open_id", :action => "new") %>
20
20
  </td>
21
21
  </tr>
22
22
  </tfoot>
@@ -24,7 +24,7 @@
24
24
  <%- if @open_id_credentials.empty? -%>
25
25
  <tr>
26
26
  <td colspan="4" style="padding: 1em;">
27
- OpenID認証は、登録されていません。
27
+ <%=h p_("MultiAuth", "There are no OpenID authentication.") %>
28
28
  </td>
29
29
  </tr>
30
30
  <%- else -%>
@@ -33,21 +33,21 @@
33
33
  <td><%=h yyyymmdd(open_id_credential.created_at) %></td>
34
34
  <td><%=h yyyymmdd_hhmm(open_id_credential.loggedin_at) %></td>
35
35
  <td style="font-family: monospace;"><%=h open_id_credential.identity_url %></td>
36
- <td><%= link_to(delete_icon + h(" 削除"), :controller => "credentials/open_id", :action => "delete", :open_id_credential_id => open_id_credential.id) %></td>
36
+ <td><%= link_to(delete_icon + h(" " + p_("MultiAuth", "Delete")), :controller => "credentials/open_id", :action => "delete", :open_id_credential_id => open_id_credential.id) %></td>
37
37
  </tr>
38
38
  <%- } -%>
39
39
  <%- end -%>
40
40
  </tbody>
41
41
  </table>
42
42
 
43
- <h2>メールアドレス認証</h2>
43
+ <h2><%=h p_("MultiAuth", "Email address authentication") %></h2>
44
44
 
45
45
  <table class="list">
46
46
  <thead>
47
47
  <tr>
48
- <th>登録日</th>
49
- <th>最終ログイン日時</th>
50
- <th>メールアドレス</th>
48
+ <th><%=h s_("EmailCredential|Activated on") %></th>
49
+ <th><%=h s_("EmailCredential|Loggedin at") %></th>
50
+ <th><%=h s_("EmailCredential|Email") %></th>
51
51
  <th colspan="2">&nbsp;</th>
52
52
  </tr>
53
53
  </thead>
@@ -55,7 +55,7 @@
55
55
  <tr>
56
56
  <td colspan="6">
57
57
  <%- can_add_email_credential = (@email_credentials.size < EmailCredential::MaximumRecordsPerUser) -%>
58
- <%= link_to_if(can_add_email_credential, add_icon + h(" メールアドレス認証を追加する"), :controller => "credentials/email", :action => "new") %>
58
+ <%= link_to_if(can_add_email_credential, add_icon + h(" " + p_("MultiAuth", "Add email address authentication")), :controller => "credentials/email", :action => "new") %>
59
59
  </td>
60
60
  </tr>
61
61
  </tfoot>
@@ -63,7 +63,7 @@
63
63
  <%- if @email_credentials.empty? -%>
64
64
  <tr>
65
65
  <td colspan="5" style="padding: 1em;">
66
- メールアドレス認証は、登録されていません。
66
+ <%=h p_("MultiAuth", "There are no email address authentication.") %>
67
67
  </td>
68
68
  </tr>
69
69
  <%- else -%>
@@ -74,11 +74,11 @@
74
74
  <td>
75
75
  <div style="font-family: monospace;"><%= email_credential.email %></div>
76
76
  <%- unless email_credential.activated? -%>
77
- <div>アクティベーション待ち</div>
77
+ <div><%=h p_("MultiAuth", "Waiting for activation") %></div>
78
78
  <%- end -%>
79
79
  </td>
80
- <td><%= link_to(icon16("icons/fam/key.png", "パスワード変更") + h(" パスワード変更"), :controller => "credentials/email", :action => "edit_password", :email_credential_id => email_credential.id) %></td>
81
- <td><%= link_to(delete_icon + h(" 削除"), :controller => "credentials/email", :action => "delete", :email_credential_id => email_credential.id) %></td>
80
+ <td><%= link_to(icon16("icons/fam/key.png", p_("MultiAuth", "Update password")) + h(" " + p_("MultiAuth", "Update password")), :controller => "credentials/email", :action => "edit_password", :email_credential_id => email_credential.id) %></td>
81
+ <td><%= link_to(delete_icon + h(" " + p_("MultiAuth", "Delete")), :controller => "credentials/email", :action => "delete", :email_credential_id => email_credential.id) %></td>
82
82
  </tr>
83
83
  <%- } -%>
84
84
  <%- end -%>
@@ -1,9 +1,12 @@
1
1
 
2
- <%- @title = "OpenIDログイン情報の削除" -%>
2
+ <%- @title = p_("MultiAuth", "Delete OpenID authentication credential.") -%>
3
3
 
4
4
  <h1><%=h @title %></h1>
5
5
 
6
- <div>削除します。よろしいですか?</div>
6
+ <div>
7
+ <%=h p_("MultiAuth", "Delete OpenID authentication credential.") %>
8
+ <%=h p_("MultiAuth", "Are you sure?") %>
9
+ </div>
7
10
 
8
11
  <table>
9
12
  <tr>
@@ -13,5 +16,5 @@
13
16
  </table>
14
17
 
15
18
  <%- form_tag(:action => "destroy") { -%>
16
- <div><%= submit_tag("削除") %></div>
19
+ <div><%= submit_tag(p_("MultiAuth", "Delete")) %></div>
17
20
  <%- } -%>
@@ -1,5 +1,5 @@
1
1
 
2
- <%- @title = "OpenID認証情報の追加" -%>
2
+ <%- @title = p_("MultiAuth", "Add OpenID authentication credential") -%>
3
3
 
4
4
  <h1><%=h @title %></h1>
5
5
 
@@ -13,7 +13,7 @@
13
13
  </td>
14
14
  </tr>
15
15
  </table>
16
- <div><%= submit_tag("追加") %></div>
16
+ <div><%= submit_tag(p_("MultiAuth", "Add")) %></div>
17
17
  <%- } -%>
18
18
 
19
19
  <%- unless production? -%>
@@ -1,14 +1,14 @@
1
-
2
- <%-
3
- item = proc { |num, html|
4
- %|<li class="#{step == num ? "active" : "inactive"}">| + html + %|</li>|
5
- }
6
- -%>
7
-
8
- <ol id="email-signup-progress">
9
- <%= item[1, "ログイン情報の入力"] %>
10
- <%= item[2, "ログイン情報の確認"] %>
11
- <%= item[3, "仮登録の完了"] %>
12
- <%= item[4, "本登録の確認"] %>
13
- <%= item[5, "本登録の完了"] %>
14
- </ol>
1
+
2
+ <%-
3
+ item = proc { |num, html|
4
+ %|<li class="#{step == num ? "active" : "inactive"}">| + html + %|</li>|
5
+ }
6
+ -%>
7
+
8
+ <ol id="email-signup-progress">
9
+ <%= item[1, p_("MultiAuth", "Input login info")] %>
10
+ <%= item[2, p_("MultiAuth", "Confirm login info")] %>
11
+ <%= item[3, p_("MultiAuth", "Pre-registration completed")] %>
12
+ <%= item[4, p_("MultiAuth", "Registration confirmation")] %>
13
+ <%= item[5, p_("MultiAuth", "Registration completed")] %>
14
+ </ol>
@@ -1,9 +1,9 @@
1
1
 
2
- <%- @title = "サインアップ" -%>
2
+ <%- @title = p_("MultiAuth", "Signup") -%>
3
3
 
4
- <h1>本登録完了</h1>
4
+ <h1><%=h p_("MultiAuth", "Registration completed") %></h1>
5
5
 
6
6
  <%= render(:partial => "progress", :locals => {:step => 5}) %>
7
7
 
8
- <div>登録が完了しました。</div>
9
- <div><%= link_to(h("ログインする"), :controller => "auth/email") %></div>
8
+ <div><%=h p_("MultiAuth", "Registration completed") %></div>
9
+ <div><%= link_to(h(p_("MultiAuth", "Login")), :controller => "auth/email") %></div>
@@ -1,27 +1,27 @@
1
1
 
2
- <%- @title = "サインアップ" -%>
2
+ <%- @title = p_("MultiAuth", "Signup") -%>
3
3
 
4
- <h1>本登録確認</h1>
4
+ <h1><%=h p_("MultiAuth", "Registration confirmation") %></h1>
5
5
 
6
6
  <%= render(:partial => "progress", :locals => {:step => 4}) %>
7
7
 
8
8
  <%- if @credential -%>
9
- <div>有効なアクティベーションキー</div>
9
+ <div><%=h p_("MultiAuth", "Valid activation token") %></div>
10
10
  <%- if @activated -%>
11
- <div>アクティベート済み</div>
11
+ <div><%=h p_("MultiAuth", "Activated") %></div>
12
12
  <%- else -%>
13
- <div>未アクティベート</div>
13
+ <div><%=h p_("MultiAuth", "Inactivated") %></div>
14
14
  <table>
15
15
  <tr>
16
- <th>メールアドレス</th>
16
+ <th><%=h s_("EmailCredential|Email") %></th>
17
17
  <td><%=h @credential.email %></td>
18
18
  </tr>
19
19
  </table>
20
20
  <%- form_tag(:action => "activate") { -%>
21
21
  <%= hidden_field_tag("activation_token", @credential.activation_token) %>
22
- <%= submit_tag("本登録") %>
22
+ <%= submit_tag(p_("MultiAuth", "Regist")) %>
23
23
  <%- } -%>
24
24
  <%- end -%>
25
25
  <%- else -%>
26
- <div>無効なアクティベーションキー</div>
26
+ <div><%=h p_("MultiAuth", "Invalid activation token") %></div>
27
27
  <%- end -%>
@@ -1,14 +1,16 @@
1
1
 
2
- <%- @title = "サインアップ" -%>
2
+ <%- @title = p_("MultiAuth", "Signup") -%>
3
3
 
4
- <h1>仮登録完了</h1>
4
+ <h1><%=h p_("MultiAuth", "Pre-registration completed") %></h1>
5
5
 
6
6
  <%= render(:partial => "progress", :locals => {:step => 3}) %>
7
7
 
8
- <%=h @signup_form.email %>宛にメールを送信しました。
8
+ <p>
9
+ <%=h p_("MultiAuth", "Sent a mail to %{email}." % { :email => @signup_form.email } ) %>
10
+ </p>
9
11
 
10
12
  <%- unless production? -%>
11
13
  <div class="debug">
12
- <%= link_to(h("アクティベーション"), :action => "activation", :activation_token => @credential.activation_token) %>
14
+ <%= link_to(h("Activation"), :action => "activation", :activation_token => @credential.activation_token) %>
13
15
  </div>
14
16
  <%- end -%>
@@ -1,7 +1,7 @@
1
1
 
2
- <%- @title = "サインアップ" -%>
2
+ <%- @title = p_("MultiAuth", "Signup") -%>
3
3
 
4
- <h1>メールアドレスによるサインアップ</h1>
4
+ <h1><%=h p_("MultiAuth", "Signup by email address") %></h1>
5
5
 
6
6
  <%= render(:partial => "progress", :locals => {:step => 1}) %>
7
7
 
@@ -24,7 +24,7 @@
24
24
  </td>
25
25
  </tr>
26
26
  </table>
27
- <div><%= submit_tag("確認画面へ") %></div>
27
+ <div><%= submit_tag(p_("MultiAuth", "Confirm")) %></div>
28
28
  <%- } -%>
29
29
 
30
30
  <%- unless production? -%>
@@ -1,21 +1,21 @@
1
1
 
2
- <%- @title = "サインアップ" -%>
2
+ <%- @title = p_("MultiAuth", "Signup") -%>
3
3
 
4
- <h1>登録確認</h1>
4
+ <h1><%=h p_("MultiAuth", "Registration confirmation") %></h1>
5
5
 
6
6
  <%= render(:partial => "progress", :locals => {:step => 2}) %>
7
7
 
8
8
  <table>
9
9
  <tr>
10
- <th>メールアドレス</th>
10
+ <th><%=h s_("EmailCredential|Email") %></th>
11
11
  <td><%=h @signup_form.email %></td>
12
12
  </tr>
13
13
  <tr>
14
- <th>パスワード</th>
14
+ <th><%=h s_("EmailCredential|Password") %></th>
15
15
  <td><%=h @signup_form.masked_password %></td>
16
16
  </tr>
17
17
  </table>
18
18
 
19
19
  <%- form_tag(:action => "create") { -%>
20
- <div><%= submit_tag("登録") %></div>
20
+ <div><%= submit_tag(p_("MultiAuth", "Register")) %></div>
21
21
  <%- } -%>
@@ -1,15 +1,21 @@
1
1
 
2
- <%- @title = "アカウント登録" -%>
2
+ <%- @title = p_("MultiAuth", "Register your account") -%>
3
3
  <%- @enable_side_column = false -%>
4
4
 
5
- <h1>さあ、<%= MultiAuth.application_name %>をはじめよう</h1>
5
+ <h1><%=h p_("MultiAuth", "Let's start %{app}!" % { :app => MultiAuth.application_name } ) %></h1>
6
6
 
7
- <div><%= MultiAuth.application_name %>のアカウント登録はとても簡単!</div>
7
+ <div><%=h p_("MultiAuth", "Registration is very easy.") %></div>
8
8
 
9
9
  <div>
10
10
  <div style="float: left; width: 45%; margin-right: 10px;">
11
- <h2>OpenIDで登録!</h2>
12
- <div>登録の流れ: OpenIDを入力 → OpenID認証 → 確認 → 登録完了!</div>
11
+ <h2><%=h p_("MultiAuth", "Register by OpenID!") %></h2>
12
+ <div>
13
+ <%- steps = [p_("MultiAuth", "Input OpenID"),
14
+ p_("MultiAuth", "OpenID Authentication"),
15
+ p_("MultiAuth", "Confirmation"),
16
+ p_("MultiAuth", "Registration completed!")] -%>
17
+ <%=h p_("MultiAuth", "Flow") %>: <%=h steps.join(" -> ") %>
18
+ </div>
13
19
  <%- form_tag(:controller => "signup/open_id", :action => "authenticate") { -%>
14
20
  <table>
15
21
  <tr>
@@ -19,12 +25,19 @@
19
25
  </td>
20
26
  </tr>
21
27
  </table>
22
- <div><%= submit_tag("次へ") %></div>
28
+ <div><%= submit_tag(p_("MultiAuth", "Next")) %></div>
23
29
  <%- } -%>
24
30
  </div>
25
31
  <div style="float: left; width: 45%;">
26
- <h2>メールアドレスで登録!</h2>
27
- <div>登録の流れ: メールアドレスとパスワードを入力 → 確認 → 確認メール受信 → 確認 → 登録完了!</div>
32
+ <h2><%=h p_("MultiAuth", "Register by email address") %></h2>
33
+ <div>
34
+ <%- steps = [p_("MultiAuth", "Input email address and password"),
35
+ p_("MultiAuth", "Confirmation"),
36
+ p_("MultiAuth", "Recieve confirmation mail"),
37
+ p_("MultiAuth", "Confirmation"),
38
+ p_("MultiAuth", "Registration completed!")] -%>
39
+ <%=h p_("MultiAuth", "Flow") %>: <%=h steps.join(" -> ") %>
40
+ </div>
28
41
  <%- form_for(:signup_form, @signup_form, :url => {:controller => "signup/email", :action => "validate"}) { |f| -%>
29
42
  <table>
30
43
  <tr>
@@ -44,7 +57,7 @@
44
57
  </td>
45
58
  </tr>
46
59
  </table>
47
- <div><%= submit_tag("確認画面へ") %></div>
60
+ <div><%= submit_tag(p_("MultiAuth", "Confirm")) %></div>
48
61
  <%- } -%>
49
62
  </div>
50
63
  <div style="clear: left;"></div>
@@ -1,7 +1,7 @@
1
1
 
2
- <%- @title = "サインアップ" -%>
2
+ <%- @title = p_("MultiAuth", "Signup") -%>
3
3
 
4
- <h1>認証完了</h1>
4
+ <h1><%=h p_("MultiAuth", "Authentication completed") %></h1>
5
5
 
6
6
  <table>
7
7
  <tr>
@@ -11,5 +11,5 @@
11
11
  </table>
12
12
 
13
13
  <%- form_tag(:action => "create") { -%>
14
- <div><%= submit_tag("登録") %></div>
14
+ <div><%= submit_tag(p_("MultiAuth", "Register")) %></div>
15
15
  <%- } -%>
@@ -1,6 +1,6 @@
1
1
 
2
- <%- @title = "サインアップ" -%>
2
+ <%- @title = p_("MultiAuth", "Signup") -%>
3
3
 
4
- <h1>登録完了</h1>
4
+ <h1><%=h p_("MultiAuth", "Registration completed") %></h1>
5
5
 
6
- <p><%= link_to('ログイン', :controller => "auth/open_id") %></p>
6
+ <p><%= link_to(h(p_("MultiAuth", "Login")), :controller => "auth/open_id") %></p>
@@ -1,7 +1,7 @@
1
1
 
2
- <%- @title = "サインアップ" -%>
2
+ <%- @title = p_("MultiAuth", "Signup") -%>
3
3
 
4
- <h1>サインアップ</h1>
4
+ <h1><%=h @title %></h1>
5
5
 
6
6
  <%- form_tag(:action => "authenticate") { -%>
7
7
  <table>
@@ -12,5 +12,5 @@
12
12
  </td>
13
13
  </tr>
14
14
  </table>
15
- <div><%= submit_tag("次へ") %></div>
15
+ <div><%= submit_tag(p_("MultiAuth", "Next")) %></div>
16
16
  <%- } -%>
@@ -0,0 +1,7 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %>
7
+ wip: --tags @wip:3 --wip features
data/config/database.yml CHANGED
@@ -9,7 +9,7 @@ development:
9
9
  # Warning: The database defined as "test" will be erased and
10
10
  # re-generated from your development database when you run "rake".
11
11
  # Do not set this db to the same as development or production.
12
- test:
12
+ test: &TEST
13
13
  adapter: sqlite3
14
14
  database: db/test.sqlite3
15
15
  pool: 5
@@ -20,3 +20,6 @@ production:
20
20
  database: db/production.sqlite3
21
21
  pool: 5
22
22
  timeout: 5000
23
+
24
+ cucumber:
25
+ <<: *TEST
@@ -2,7 +2,7 @@
2
2
  # Be sure to restart your server when you modify this file
3
3
 
4
4
  # Specifies gem version of Rails to use when vendor/rails is not present
5
- RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION
5
+ RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
6
6
 
7
7
  # Bootstrap the Rails environment, frameworks, and default configuration
8
8
  require File.join(File.dirname(__FILE__), 'boot')
data/config/routes.rb CHANGED
@@ -5,25 +5,32 @@ ActionController::Routing::Routes.draw do |map|
5
5
  TokenPattern = /[0-9a-f]+/
6
6
 
7
7
  if Rails.root.to_s == File.expand_path(File.join(File.dirname(__FILE__), '..'))
8
- map.root :controller => "home", :action => "index"
8
+ map.root :controller => "home", :conditions => { :method => :get }
9
9
  end
10
10
 
11
- map.connect "signup", :controller => "signup", :action => "index"
11
+ map.signup "signup", :controller => "signup", :conditions => { :method => :get }
12
12
 
13
- map.with_options :controller => "signup/email" do |email|
14
- email.connect "signup/email/:action", :action => /(index|validate|validated|create|created|activate|activated)/
15
- email.connect "signup/email/activation/:activation_token", :action => "activation", :activation_token => TokenPattern
13
+ map.namespace :signup do |signup|
14
+ signup.with_options :controller => "email" do |email|
15
+ email.connect "email/:action", :action => /(index|validate|validated|create|created|activate|activated)/
16
+ email.connect "email/activation/:activation_token", :action => "activation", :activation_token => TokenPattern
17
+ end
18
+ signup.with_options :controller => "open_id" do |open_id|
19
+ open_id.connect "open_id/:action", :action => /(index|authenticate|authenticated|create|created)/
20
+ end
16
21
  end
17
22
 
18
- map.with_options :controller => "signup/open_id" do |open_id|
19
- open_id.connect "signup/open_id/:action", :action => /(index|authenticate|authenticated|create|created)/
23
+ map.with_options :controller => "auth" do |auth|
24
+ auth.auth "auth", :action => "index", :conditions => { :method => :get }
25
+ auth.logout "auth/logout", :action => "logout", :conditions => { :method => :post }
26
+ auth.connect "auth/:action", :action => /(logged_in|logged_out)/, :conditions => { :method => :get }
27
+ end
28
+ map.namespace :auth do |auth|
29
+ auth.connect "email/:action", :controller => "email", :action => /(index|login)/
30
+ auth.connect "open_id/:action", :controller => "open_id", :action => /(index|login)/
20
31
  end
21
32
 
22
- map.connect "auth/:action", :controller => "auth", :action => /(logged_in|logout|logged_out)/
23
- map.connect "auth/email/:action", :controller => "auth/email", :action => /(index|login)/
24
- map.connect "auth/open_id/:action", :controller => "auth/open_id", :action => /(index|login)/
25
-
26
- map.connect "credentials/:action", :controller => "credentials", :action => /(index)/
33
+ map.credentials "credentials", :controller => "credentials", :conditions => { :method => :get }
27
34
 
28
35
  map.with_options :controller => "credentials/email" do |email|
29
36
  email.connect "credentials/email/:action", :action => /(new|create)/
@@ -36,16 +43,10 @@ ActionController::Routing::Routes.draw do |map|
36
43
  open_id.connect "credential/open_id/:open_id_credential_id/:action", :action => /(delete|destroy)/, :open_id_credential_id => IdPattern
37
44
  end
38
45
 
39
- map.with_options :controller => "emails" do |emails|
40
- emails.connect "emails/:action", :action => /(new|create)/
41
- emails.connect "email/:email_address_id/:action", :action => /(created|delete|destroy)/, :email_address_id => IdPattern
42
- emails.connect "email/token/:activation_token/:action", :action => /(activation|activate|activated)/, :activation_token => TokenPattern
43
- end
44
-
45
46
  # MEMO: 下記2行のデフォルトルールをコメントアウトしてrake test:functionalsを
46
47
  # 実行することにより、リンクチェックを行うことができる
47
48
  # NOTE: この二行を有効にするとアプリケーション側の config/routes.rb で定義した
48
49
  # ルートが有効にならない
49
- map.connect ":controller/:action/:id"
50
- map.connect ":controller/:action/:id.:format"
50
+ # map.connect ":controller/:action/:id"
51
+ # map.connect ":controller/:action/:id.:format"
51
52
  end
data/db/test.sqlite3 CHANGED
Binary file
@@ -11,6 +11,14 @@ module MultiAuth
11
11
  end
12
12
  end
13
13
  module InstanceMethods
14
+
15
+ def self.included(base)
16
+ base.class_eval{
17
+ init_gettext("multi_auth",
18
+ :locale_path => MultiAuth.root + 'locale')
19
+ }
20
+ end
21
+
14
22
  private
15
23
 
16
24
  def authentication(user_id = session[:user_id])
@@ -19,15 +27,38 @@ module MultiAuth
19
27
  end
20
28
 
21
29
  def authentication_required
30
+ if session[:expires_at]
31
+ if session_expired?
32
+ logger.info "[MultiAuth] Session has expired, resetting session"
33
+ reset_login_session
34
+ set_error(p_("MultiAuth", "Session has expired. Please login again."))
35
+ return false
36
+ end
37
+ update_session_expiry
38
+ end
39
+
22
40
  if @login_user
23
41
  return true
24
42
  else
25
- set_error("ログインが必要です。")
43
+ set_error(p_("MultiAuth", "Login required."))
26
44
  redirect_to(root_path)
27
45
  return false
28
46
  end
29
47
  end
30
48
 
49
+ def update_session_expiry
50
+ return unless MultiAuth.session_times_out_in
51
+ session[:expires_at] = Time.now + MultiAuth.session_times_out_in
52
+ end
53
+
54
+ def session_expired?
55
+ Time.now > session[:expires_at]
56
+ end
57
+
58
+ def reset_login_session
59
+ session[:user_id] = nil
60
+ end
61
+
31
62
  def set_notice(message)
32
63
  flash[:notice] = @flash_notice = message
33
64
  flash[:error] = @flash_error = nil
data/lib/multi_auth.rb CHANGED
@@ -6,6 +6,7 @@ module MultiAuth
6
6
  attr_accessor_with_default :application_name, 'app'
7
7
  attr_accessor_with_default :from_address, 'noreply@example.com'
8
8
  attr_accessor_with_default :user_model, 'User'
9
+ attr_accessor_with_default :session_times_out_in, 1.hour
9
10
  def setup
10
11
  yield self
11
12
  end
@@ -14,6 +15,10 @@ module MultiAuth
14
15
  def self.user_model_class
15
16
  user_model.constantize
16
17
  end
18
+
19
+ def self.root
20
+ Pathname.new(File.join(File.dirname(__FILE__), '../'))
21
+ end
17
22
  end
18
23
 
19
24
  require 'multi_auth/action_controller'
@@ -2,11 +2,11 @@
2
2
  module OpenIdAuthentication
3
3
  class Result
4
4
  ERROR_MESSAGES.update({
5
- :missing => "OpenID サーバが見つかりませんでした。",
6
- :invalid => "OpenID が不正です。",
7
- :canceled => "OpenID の検証がキャンセルされました。",
8
- :failed => "OpenID の検証が失敗しました。",
9
- :setup_needed => "OpenID の検証には準備が必要です。",
5
+ :missing => p_("OpenIdAuthentication", "Sorry, the OpenID server couldn't be found"),
6
+ :invalid => p_("OpenIdAuthentication", "Sorry, but this does not appear to be a valid OpenID"),
7
+ :canceled => p_("OpenIdAuthentication", "OpenID verification was canceled"),
8
+ :failed => p_("OpenIdAuthentication", "OpenID verification failed"),
9
+ :setup_needed => p_("OpenIdAuthentication", "OpenID verification needs setup"),
10
10
  })
11
11
  end
12
12
  end
Binary file