okkez-multi_auth 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,6 @@
3
3
  class ApplicationController < ActionController::Base
4
4
  helper :all # include all helpers, all the time
5
5
  protect_from_forgery # See ActionController::RequestForgeryProtection for details
6
- before_filter { |c| c.instance_eval { @topic_path = [] }; true }
7
6
 
8
7
  GetText.locale = "ja"
9
8
  init_gettext "multi_auth"
@@ -20,7 +20,7 @@ class Auth::OpenIdController < ApplicationController
20
20
  @open_id_credential = OpenIdCredential.find_by_identity_url(identity_url)
21
21
  if @open_id_credential
22
22
  @open_id_credential.login!
23
- session[:user_id] = @open_id_credential.user.id
23
+ session[:user_id] = @open_id_credential.user_id
24
24
  flash[:notice] = "ログインしました。"
25
25
  redirect_to(root_path)
26
26
  else
@@ -4,6 +4,11 @@
4
4
  class AuthController < ApplicationController
5
5
  verify_method_post :only => [:logout]
6
6
 
7
+ # GET /auth/index
8
+ def index
9
+ # nop
10
+ end
11
+
7
12
  # GET /auth/logged_in
8
13
  def logged_in
9
14
  @return_path = params[:return_path]
@@ -62,7 +62,7 @@
62
62
 
63
63
  <div id="dialog">
64
64
  <h1>ログイン</h1>
65
- <%- form_for(:login_form, @login_form, :url => {:action => "login"}) { |f| -%>
65
+ <%- form_for(:login_form, @login_form, :url => {:action => "login"}) do |f| -%>
66
66
  <table id="email-login">
67
67
  <tr>
68
68
  <th><%= f.label(:email) %></th>
@@ -79,8 +79,8 @@
79
79
  </td>
80
80
  </tr>
81
81
  </table>
82
- <div style="text-align: center;"><%= submit_tag("ログイン") %></div>
83
- <%- } -%>
82
+ <%= submit_tag("ログイン") %>
83
+ <%- end -%>
84
84
  </div>
85
85
 
86
86
  <%- unless production? -%>
@@ -0,0 +1,49 @@
1
+ <%- @title = "ログイン" -%>
2
+ <%- @enable_side_column = false -%>
3
+
4
+ <div id="dialog">
5
+ <h1>OpenID によるログイン</h1>
6
+
7
+ <%- form_tag(:controller => 'auth/open_id', :action => "login") do -%>
8
+ <table>
9
+ <tr>
10
+ <th><%= label_tag(:openid_url, "OpenID") %></th>
11
+ <td>
12
+ <%= text_field_tag(:openid_url, "", :size => 30) %>
13
+ </td>
14
+ </tr>
15
+ </table>
16
+ <div><%= submit_tag("ログイン") %></div>
17
+ <%- end -%>
18
+
19
+ <hr />
20
+
21
+ <h1>メールアドレスでログイン</h1>
22
+ <%- form_for(:login_form, @login_form, :url => { :controller => 'auth/email', :action => "login"}) do |f| -%>
23
+ <table id="email-login">
24
+ <tr>
25
+ <th><%= f.label(:email) %></th>
26
+ <td>
27
+ <%= f.text_field(:email, :size => 30) %>
28
+ <%= error_message_on(:login_form, :email) %>
29
+ </td>
30
+ </tr>
31
+ <tr>
32
+ <th><%= f.label(:password) %></th>
33
+ <td>
34
+ <%= f.password_field(:password, :size => 30) %>
35
+ <%= error_message_on(:login_form, :password) %>
36
+ </td>
37
+ </tr>
38
+ </table>
39
+ <%= submit_tag("ログイン") %>
40
+ <%- end -%>
41
+
42
+ </div>
43
+
44
+ <%- unless production? -%>
45
+ <div class="debug">
46
+ <%= error_messages_for(:login_form) %>
47
+ </div>
48
+ <%- end -%>
49
+
@@ -6,7 +6,7 @@
6
6
  <h1>OpenID によるログイン</h1>
7
7
 
8
8
  <%- form_tag(:action => "login") do -%>
9
- <table border="1">
9
+ <table>
10
10
  <tr>
11
11
  <th><%= label_tag(:openid_url, "OpenID") %></th>
12
12
  <td>
@@ -3,7 +3,7 @@
3
3
 
4
4
  <h1><%=h @title %></h1>
5
5
 
6
- <table border="1">
6
+ <table>
7
7
  <tr>
8
8
  <th>メールアドレス</th>
9
9
  <td><%=h @email_credential.email %></td>
@@ -1,8 +1,5 @@
1
1
 
2
2
  <%- @title = "仮登録完了" -%>
3
- <%- @topic_path << ["トップ", root_path] -%>
4
- <%- @topic_path << ["ログイン設定", url_for(:controller => "/credentials")] -%>
5
- <%- @topic_path << [@title] -%>
6
3
 
7
4
  <h1><%=h @title %></h1>
8
5
 
@@ -1,14 +1,11 @@
1
1
 
2
2
  <%- @title = "メールログイン情報の削除" -%>
3
- <%- @topic_path << ["トップ", root_path] -%>
4
- <%- @topic_path << ["ログイン設定", url_for(:controller => "/credentials")] -%>
5
- <%- @topic_path << [@title] -%>
6
3
 
7
4
  <h1><%=h @title %></h1>
8
5
 
9
6
  <div>削除します。よろしいですか?</div>
10
7
 
11
- <table border="1">
8
+ <table>
12
9
  <tr>
13
10
  <th>メールアドレス</th>
14
11
  <td><%=h @email_credential.email %></td>
@@ -1,13 +1,10 @@
1
1
 
2
2
  <%- @title = "パスワードの変更" -%>
3
- <%- @topic_path << ["トップ", root_path] -%>
4
- <%- @topic_path << ["ログイン設定", url_for(:controller => "/credentials")] -%>
5
- <%- @topic_path << [@title] -%>
6
3
 
7
4
  <h1><%=h @title %></h1>
8
5
 
9
6
  <%- form_for(:edit_form, @edit_form, :url => {:action => "update_password"}) { |f| -%>
10
- <table border="1">
7
+ <table>
11
8
  <tr>
12
9
  <th>メールアドレス</th>
13
10
  <td><%=h @email_credential.email %></td>
@@ -1,13 +1,10 @@
1
1
 
2
2
  <%- @title = "メール認証情報の追加" -%>
3
- <%- @topic_path << ["トップ", root_path] -%>
4
- <%- @topic_path << ["ログイン設定", url_for(:controller => "/credentials")] -%>
5
- <%- @topic_path << [@title] -%>
6
3
 
7
4
  <h1><%=h @title %></h1>
8
5
 
9
6
  <%- form_for(:edit_form, @edit_form, :url => {:action => "create"}) { |f| -%>
10
- <table border="1">
7
+ <table>
11
8
  <tr>
12
9
  <th><%= f.label(:email) %></th>
13
10
  <td>
@@ -1,7 +1,5 @@
1
1
 
2
2
  <%- @title = "ログイン設定" -%>
3
- <%- @topic_path << ["トップ", root_path] -%>
4
- <%- @topic_path << [@title] -%>
5
3
 
6
4
  <h2>OpenID認証</h2>
7
5
 
@@ -1,20 +1,17 @@
1
-
2
- <%- @title = "OpenIDログイン情報の削除" -%>
3
- <%- @topic_path << ["トップ", root_path] -%>
4
- <%- @topic_path << ["ログイン設定", url_for(:controller => "/credentials")] -%>
5
- <%- @topic_path << [@title] -%>
6
-
7
- <h1><%=h @title %></h1>
8
-
9
- <div>削除します。よろしいですか?</div>
10
-
11
- <table border="1">
12
- <tr>
13
- <th>OpenID</th>
14
- <td><%=h @open_id_credential.identity_url %></td>
15
- </tr>
16
- </table>
17
-
18
- <%- form_tag(:action => "destroy") { -%>
19
- <div><%= submit_tag("削除") %></div>
20
- <%- } -%>
1
+
2
+ <%- @title = "OpenIDログイン情報の削除" -%>
3
+
4
+ <h1><%=h @title %></h1>
5
+
6
+ <div>削除します。よろしいですか?</div>
7
+
8
+ <table>
9
+ <tr>
10
+ <th>OpenID</th>
11
+ <td><%=h @open_id_credential.identity_url %></td>
12
+ </tr>
13
+ </table>
14
+
15
+ <%- form_tag(:action => "destroy") { -%>
16
+ <div><%= submit_tag("削除") %></div>
17
+ <%- } -%>
@@ -1,13 +1,10 @@
1
1
 
2
2
  <%- @title = "OpenID認証情報の追加" -%>
3
- <%- @topic_path << ["トップ", root_path] -%>
4
- <%- @topic_path << ["ログイン設定", url_for(:controller => "/credentials")] -%>
5
- <%- @topic_path << [@title] -%>
6
3
 
7
4
  <h1><%=h @title %></h1>
8
5
 
9
6
  <%- form_for(:login_form, @login_form, :url => {:action => "create"}) { |f| -%>
10
- <table border="1">
7
+ <table>
11
8
  <tr>
12
9
  <th><%= f.label(:openid_url) %></th>
13
10
  <td>
@@ -11,7 +11,7 @@
11
11
  <div>アクティベート済み</div>
12
12
  <%- else -%>
13
13
  <div>未アクティベート</div>
14
- <table border="1">
14
+ <table>
15
15
  <tr>
16
16
  <th>メールアドレス</th>
17
17
  <td><%=h @credential.email %></td>
@@ -6,7 +6,7 @@
6
6
  <%= render(:partial => "progress", :locals => {:step => 1}) %>
7
7
 
8
8
  <%- form_for(:signup_form, @signup_form, :url => {:action => "validate"}) { |f| -%>
9
- <table border="1">
9
+ <table>
10
10
  <tr>
11
11
  <th><%= f.label(:email) %></th>
12
12
  <td>
@@ -5,7 +5,7 @@
5
5
 
6
6
  <%= render(:partial => "progress", :locals => {:step => 2}) %>
7
7
 
8
- <table border="1">
8
+ <table>
9
9
  <tr>
10
10
  <th>メールアドレス</th>
11
11
  <td><%=h @signup_form.email %></td>
@@ -11,7 +11,7 @@
11
11
  <h2>OpenIDで登録!</h2>
12
12
  <div>登録の流れ: OpenIDを入力 → OpenID認証 → 確認 → 登録完了!</div>
13
13
  <%- form_tag(:controller => "signup/open_id", :action => "authenticate") { -%>
14
- <table border="1">
14
+ <table>
15
15
  <tr>
16
16
  <th><%= label_tag("openid_url", "OpenID URL") %></th>
17
17
  <td>
@@ -26,7 +26,7 @@
26
26
  <h2>メールアドレスで登録!</h2>
27
27
  <div>登録の流れ: メールアドレスとパスワードを入力 → 確認 → 確認メール受信 → 確認 → 登録完了!</div>
28
28
  <%- form_for(:signup_form, @signup_form, :url => {:controller => "signup/email", :action => "validate"}) { |f| -%>
29
- <table border="1">
29
+ <table>
30
30
  <tr>
31
31
  <th><%= f.label(:email) %></th>
32
32
  <td>
@@ -3,7 +3,7 @@
3
3
 
4
4
  <h1>認証完了</h1>
5
5
 
6
- <table border="1">
6
+ <table>
7
7
  <tr>
8
8
  <th>OpenID</th>
9
9
  <td><%=h @identity_url %></td>
@@ -4,7 +4,7 @@
4
4
  <h1>サインアップ</h1>
5
5
 
6
6
  <%- form_tag(:action => "authenticate") { -%>
7
- <table border="1">
7
+ <table>
8
8
  <tr>
9
9
  <th><%= label_tag("openid_url", "OpenID URL") %></th>
10
10
  <td>
Binary file
data/db/test.sqlite3 CHANGED
Binary file
@@ -46,5 +46,3 @@ module MultiAuth
46
46
  end
47
47
  end
48
48
 
49
- ActionController::Base.__send__(:extend, MultiAuth::ActionController::ClassMethods)
50
- ActionController::Base.__send__(:include, MultiAuth::ActionController::InstanceMethods)
@@ -12,5 +12,3 @@ module MultiAuth
12
12
  end
13
13
  end
14
14
 
15
- ActiveRecord::Base.__send__(:extend, MultiAuth::ActiveRecord::ClassMethods)
16
-
data/rails/init.rb CHANGED
@@ -28,3 +28,8 @@ config.action_mailer.raise_delivery_errors = true
28
28
  config.action_mailer.delivery_method = :smtp
29
29
  config.action_mailer.smtp_settings = YAML.load_file(Rails.root + "config/smtp.yml")
30
30
 
31
+ config.to_prepare do
32
+ ActiveRecord::Base.__send__(:extend, MultiAuth::ActiveRecord::ClassMethods)
33
+ ActionController::Base.__send__(:extend, MultiAuth::ActionController::ClassMethods)
34
+ ActionController::Base.__send__(:include, MultiAuth::ActionController::InstanceMethods)
35
+ end
@@ -5,11 +5,19 @@ class AuthControllerTest < ActionController::TestCase
5
5
  test "routes" do
6
6
  base = {:controller => "auth"}
7
7
 
8
+ assert_routing("/auth", base.merge(:action => "index"))
8
9
  assert_routing("/auth/logged_in", base.merge(:action => "logged_in"))
9
- assert_routing("/auth/logout", base.merge(:action => "logout"))
10
+ assert_routing("/auth/logout", base.merge(:action => "logout"))
10
11
  assert_routing("/auth/logged_out", base.merge(:action => "logged_out"))
11
12
  end
12
13
 
14
+ test "GET index" do
15
+ get :index
16
+
17
+ assert_response(:success)
18
+ assert_template("index")
19
+ end
20
+
13
21
  test "GET logged_in" do
14
22
  return_path = "/return"
15
23
 
@@ -9,7 +9,7 @@ class MultiAuthPublicAssetsGeneratorTest < Test::Unit::TestCase
9
9
  @dest = File.expand_path(File.join(File.dirname(__FILE__), '../..', 'lib', 'generators'))
10
10
  FileUtils.ln_s(@src, @dest)
11
11
  FileUtils.mkdir_p(fake_rails_root)
12
- @original_files = file_list
12
+ @original_files = Dir.glob(File.join(fake_rails_root, '**/*'))
13
13
  end
14
14
 
15
15
  def teardown
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: okkez-multi_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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-13 00:00:00 +09:00
12
+ date: 2009-12-16 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -71,6 +71,7 @@ files:
71
71
  - app/views/credentials/email/created.html.erb
72
72
  - app/views/credentials/email/activation.html.erb
73
73
  - app/views/auth/logged_out.html.erb
74
+ - app/views/auth/index.html.erb
74
75
  - app/views/auth/open_id/index.html.erb
75
76
  - app/views/auth/email/index.html.erb
76
77
  - app/views/auth/logged_in.html.erb