okkez-multi_auth 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README +15 -1
- data/app/controllers/application_controller.rb +1 -0
- data/app/controllers/auth/email_controller.rb +1 -1
- data/app/controllers/auth/open_id_controller.rb +3 -3
- data/app/controllers/credentials/email_controller.rb +10 -9
- data/app/controllers/credentials/open_id_controller.rb +7 -1
- data/app/controllers/signup/email_controller.rb +5 -5
- data/app/controllers/signup/open_id_controller.rb +3 -1
- data/app/models/activation_mailer.rb +6 -6
- data/app/models/email_credential.rb +5 -0
- data/app/models/open_id_credential.rb +5 -0
- data/app/models/session.rb +4 -0
- data/app/views/activation_mailer/complete_for_credential.erb +1 -1
- data/app/views/activation_mailer/complete_for_notice.erb +1 -1
- data/app/views/activation_mailer/complete_for_signup.erb +1 -1
- data/app/views/activation_mailer/request_for_credential.erb +5 -5
- data/app/views/activation_mailer/request_for_notice.erb +5 -5
- data/app/views/activation_mailer/request_for_signup.erb +5 -5
- data/app/views/auth/email/index.html.erb +3 -3
- data/app/views/auth/index.html.erb +5 -5
- data/app/views/auth/logged_in.html.erb +5 -3
- data/app/views/auth/logged_out.html.erb +5 -3
- data/app/views/auth/open_id/index.html.erb +3 -3
- data/app/views/credentials/email/activated.html.erb +4 -1
- data/app/views/credentials/email/activation.html.erb +3 -3
- data/app/views/credentials/email/created.html.erb +4 -4
- data/app/views/credentials/email/delete.html.erb +7 -4
- data/app/views/credentials/email/edit_password.html.erb +4 -4
- data/app/views/credentials/email/new.html.erb +2 -2
- data/app/views/credentials/index.html.erb +16 -16
- data/app/views/credentials/open_id/delete.html.erb +6 -3
- data/app/views/credentials/open_id/new.html.erb +2 -2
- data/app/views/signup/email/_progress.html.erb +14 -14
- data/app/views/signup/email/activated.html.erb +4 -4
- data/app/views/signup/email/activation.html.erb +8 -8
- data/app/views/signup/email/created.html.erb +6 -4
- data/app/views/signup/email/index.html.erb +3 -3
- data/app/views/signup/email/validated.html.erb +5 -5
- data/app/views/signup/index.html.erb +22 -9
- data/app/views/signup/open_id/authenticated.html.erb +3 -3
- data/app/views/signup/open_id/created.html.erb +3 -3
- data/app/views/signup/open_id/index.html.erb +3 -3
- data/config/cucumber.yml +7 -0
- data/config/database.yml +4 -1
- data/config/environment.rb +1 -1
- data/config/routes.rb +21 -20
- data/db/test.sqlite3 +0 -0
- data/lib/multi_auth.rb +5 -0
- data/lib/multi_auth/action_controller.rb +32 -1
- data/lib/open_id_authentication/result.rb +5 -5
- data/locale/ja/LC_MESSAGES/multi_auth.mo +0 -0
- data/po/ja/multi_auth.po +639 -0
- data/po/multi_auth.pot +637 -0
- data/test/functional/auth/open_id_controller_test.rb +1 -1
- data/test/functional/auth_controller_test.rb +10 -7
- data/test/functional/credentials_controller_test.rb +9 -0
- data/test/unit/activation_mailer_test.rb +2 -2
- metadata +7 -2
data/README
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
MultiAuth
|
2
2
|
=========
|
3
3
|
|
4
|
-
This engine provides basic signup/login
|
4
|
+
This engine provides basic signup/login functionalities for your Rails applications.
|
5
5
|
|
6
6
|
Install
|
7
7
|
=======
|
@@ -55,6 +55,20 @@ You can use default style sheet and icons.
|
|
55
55
|
$ ruby script/generate multi_auth_public_assets
|
56
56
|
|
57
57
|
|
58
|
+
Settings
|
59
|
+
========
|
60
|
+
|
61
|
+
You can config in RAILS_ROOT/config/initializers/*.rb
|
62
|
+
|
63
|
+
Ex.
|
64
|
+
|
65
|
+
MultiAuth.setup do |s|
|
66
|
+
s.application_name = 'Your app name'
|
67
|
+
s.from_address = 'yourname@example.com'
|
68
|
+
s.user_model = 'YourUserModel'
|
69
|
+
s.session_times_out_in = 1.hour
|
70
|
+
end
|
71
|
+
|
58
72
|
Customize
|
59
73
|
=========
|
60
74
|
|
@@ -4,6 +4,7 @@ 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
6
|
|
7
|
+
# multi_auth を使用するアプリケーションには影響しない
|
7
8
|
GetText.locale = "ja"
|
8
9
|
init_gettext "multi_auth"
|
9
10
|
|
@@ -27,7 +27,7 @@ class Auth::EmailController < ApplicationController
|
|
27
27
|
redirect_to(:controller => "/auth", :action => "logged_in")
|
28
28
|
else
|
29
29
|
@login_form.password = nil
|
30
|
-
set_error_now("
|
30
|
+
set_error_now(p_("MultiAuth", "The email address or the password is wrong."))
|
31
31
|
render(:action => "index")
|
32
32
|
end
|
33
33
|
end
|
@@ -21,10 +21,10 @@ class Auth::OpenIdController < ApplicationController
|
|
21
21
|
if @open_id_credential
|
22
22
|
@open_id_credential.login!
|
23
23
|
session[:user_id] = @open_id_credential.user_id
|
24
|
-
|
24
|
+
set_notice(p_("MultiAuth", "Logged in successfully."))
|
25
25
|
redirect_to(root_path)
|
26
26
|
else
|
27
|
-
|
27
|
+
set_notice(p_("MultiAuth", "This OpenID has not been registered yet."))
|
28
28
|
redirect_to(:controller => "signup/open_id", :action => "index")
|
29
29
|
end
|
30
30
|
else
|
@@ -36,7 +36,7 @@ class Auth::OpenIdController < ApplicationController
|
|
36
36
|
private
|
37
37
|
|
38
38
|
def failed_login(message)
|
39
|
-
|
39
|
+
set_error(message)
|
40
40
|
redirect_to(root_path)
|
41
41
|
end
|
42
42
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
|
2
3
|
# メール認証情報コントローラ
|
3
4
|
class Credentials::EmailController < ApplicationController
|
@@ -37,12 +38,12 @@ class Credentials::EmailController < ApplicationController
|
|
37
38
|
:recipients => @email_credential.email,
|
38
39
|
:activation_url => @activation_url)
|
39
40
|
|
40
|
-
set_notice("
|
41
|
+
set_notice(p_("MultiAuth", "Email authentication credential was successfully added."))
|
41
42
|
redirect_to(:action => "created", :email_credential_id => @email_credential.id)
|
42
43
|
else
|
43
44
|
@edit_form.password = nil
|
44
45
|
@edit_form.password_confirmation = nil
|
45
|
-
set_error_now("
|
46
|
+
set_error_now(p_("MultiAuth", "Please confirm your input."))
|
46
47
|
render(:action => "new")
|
47
48
|
end
|
48
49
|
end
|
@@ -64,12 +65,12 @@ class Credentials::EmailController < ApplicationController
|
|
64
65
|
@email_credential.attributes = @edit_form.to_email_credential_hash
|
65
66
|
|
66
67
|
if @edit_form.valid? && @email_credential.save
|
67
|
-
set_notice("
|
68
|
+
set_notice(p_("MultiAuth", "Password was changed."))
|
68
69
|
redirect_to(:controller => "/credentials")
|
69
70
|
else
|
70
71
|
@edit_form.password = nil
|
71
72
|
@edit_form.password_confirmation = nil
|
72
|
-
set_error_now("
|
73
|
+
set_error_now(p_("MultiAuth", "Please confirm your input."))
|
73
74
|
render(:action => "edit_password")
|
74
75
|
end
|
75
76
|
end
|
@@ -83,7 +84,7 @@ class Credentials::EmailController < ApplicationController
|
|
83
84
|
def destroy
|
84
85
|
@email_credential.destroy
|
85
86
|
|
86
|
-
set_notice("
|
87
|
+
set_notice(p_("MultiAuth", "Email authentication credential was successfully deleted."))
|
87
88
|
redirect_to(:controller => "/credentials")
|
88
89
|
end
|
89
90
|
|
@@ -117,7 +118,7 @@ class Credentials::EmailController < ApplicationController
|
|
117
118
|
if @email_credential
|
118
119
|
return true
|
119
120
|
else
|
120
|
-
set_error("
|
121
|
+
set_error(p_("MultiAuth", "It is invalid email authentication credential."))
|
121
122
|
redirect_to(root_path)
|
122
123
|
return false
|
123
124
|
end
|
@@ -127,7 +128,7 @@ class Credentials::EmailController < ApplicationController
|
|
127
128
|
if @email_credential.user_id == @login_user.id
|
128
129
|
return true
|
129
130
|
else
|
130
|
-
set_error("
|
131
|
+
set_error(p_("MultiAuth", "It is invalid email authentication credential."))
|
131
132
|
redirect_to(root_path)
|
132
133
|
return false
|
133
134
|
end
|
@@ -138,7 +139,7 @@ class Credentials::EmailController < ApplicationController
|
|
138
139
|
if @email_credential
|
139
140
|
return true
|
140
141
|
else
|
141
|
-
set_error("
|
142
|
+
set_error(p_("MultiAuth", "It is invalid activation token."))
|
142
143
|
redirect_to(root_path)
|
143
144
|
return false
|
144
145
|
end
|
@@ -146,7 +147,7 @@ class Credentials::EmailController < ApplicationController
|
|
146
147
|
|
147
148
|
def only_inactive_email_credential
|
148
149
|
if @email_credential.activated?
|
149
|
-
set_error("
|
150
|
+
set_error(p_("MultiAuth", "This email authentication credential has been already activated."))
|
150
151
|
redirect_to(root_path)
|
151
152
|
return false
|
152
153
|
else
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
|
2
3
|
# OpenID認証情報コントローラ
|
3
4
|
class Credentials::OpenIdController < ApplicationController
|
@@ -18,7 +19,7 @@ class Credentials::OpenIdController < ApplicationController
|
|
18
19
|
@login_form = OpenIdLoginForm.new(params[:login_form])
|
19
20
|
|
20
21
|
if params[:open_id_complete].nil? && !@login_form.valid?
|
21
|
-
set_error_now("
|
22
|
+
set_error_now(p_("MultiAuth", "Please confirm your input."))
|
22
23
|
render(:action => "new")
|
23
24
|
return
|
24
25
|
end
|
@@ -33,9 +34,11 @@ class Credentials::OpenIdController < ApplicationController
|
|
33
34
|
if @open_id_credential.new_record?
|
34
35
|
@open_id_credential.save!
|
35
36
|
|
37
|
+
set_notice(p_("MultiAuth", "OpenID authentication credential was successfully added."))
|
36
38
|
set_notice("OpenID認証情報を追加しました。")
|
37
39
|
redirect_to(:controller => "/credentials", :action => "index")
|
38
40
|
else
|
41
|
+
set_error_now(p_("MultiAuth", "This OpenID has been already registered."))
|
39
42
|
set_error_now("既に使用されているOpenIDです。")
|
40
43
|
render(:action => "new")
|
41
44
|
end
|
@@ -55,6 +58,7 @@ class Credentials::OpenIdController < ApplicationController
|
|
55
58
|
def destroy
|
56
59
|
@open_id_credential.destroy
|
57
60
|
|
61
|
+
set_notice(p_("MultiAuth", "OpenID authentication credential was successfully deleted."))
|
58
62
|
set_notice("OpenID認証情報を削除しました。")
|
59
63
|
redirect_to(:controller => "/credentials")
|
60
64
|
end
|
@@ -67,6 +71,7 @@ class Credentials::OpenIdController < ApplicationController
|
|
67
71
|
if @open_id_credential
|
68
72
|
return true
|
69
73
|
else
|
74
|
+
set_error(p_("MultiAuth", "It is invalid OpenID authentication credential."))
|
70
75
|
set_error("OpenID認証情報IDが正しくありません。")
|
71
76
|
redirect_to(root_path)
|
72
77
|
return false
|
@@ -77,6 +82,7 @@ class Credentials::OpenIdController < ApplicationController
|
|
77
82
|
if @open_id_credential.user_id == @login_user.id
|
78
83
|
return true
|
79
84
|
else
|
85
|
+
set_error(p_("MultiAuth", "It is invalid OpenID authentication credential."))
|
80
86
|
set_error("OpenID認証情報IDが正しくありません。")
|
81
87
|
redirect_to(root_path)
|
82
88
|
return false
|
@@ -24,7 +24,7 @@ class Signup::EmailController < ApplicationController
|
|
24
24
|
else
|
25
25
|
@signup_form.password = nil
|
26
26
|
@signup_form.password_confirmation = nil
|
27
|
-
set_error_now("
|
27
|
+
set_error_now(p_("MultiAuth", "Please confirm your input."))
|
28
28
|
render(:action => "index")
|
29
29
|
end
|
30
30
|
end
|
@@ -36,7 +36,7 @@ class Signup::EmailController < ApplicationController
|
|
36
36
|
if @signup_form.valid?
|
37
37
|
render
|
38
38
|
else
|
39
|
-
set_error_now("
|
39
|
+
set_error_now(p_("MultiAuth", "Please confirm your input."))
|
40
40
|
render(:action => "index")
|
41
41
|
end
|
42
42
|
end
|
@@ -64,7 +64,7 @@ class Signup::EmailController < ApplicationController
|
|
64
64
|
|
65
65
|
redirect_to(:action => "created")
|
66
66
|
else
|
67
|
-
set_error_now("
|
67
|
+
set_error_now(p_("MultiAuth", "Please confirm your input."))
|
68
68
|
render(:action => "index")
|
69
69
|
end
|
70
70
|
end
|
@@ -90,13 +90,13 @@ class Signup::EmailController < ApplicationController
|
|
90
90
|
@credential = EmailCredential.find_by_activation_token(params[:activation_token])
|
91
91
|
|
92
92
|
unless @credential
|
93
|
-
set_error("
|
93
|
+
set_error(p_("MultiAuth", "It is an invalid activation key."))
|
94
94
|
redirect_to(root_path)
|
95
95
|
return
|
96
96
|
end
|
97
97
|
|
98
98
|
if @credential.activated?
|
99
|
-
set_error("
|
99
|
+
set_error(p_("MultiAuth", "This email address has been already registered."))
|
100
100
|
redirect_to(root_path)
|
101
101
|
return
|
102
102
|
end
|
@@ -22,7 +22,9 @@ class Signup::OpenIdController < ApplicationController
|
|
22
22
|
authenticate_with_open_id(@openid_url) { |result, identity_url, sreg|
|
23
23
|
if result.successful?
|
24
24
|
if OpenIdCredential.exists?(:identity_url => identity_url)
|
25
|
-
failed["
|
25
|
+
failed[p_("MultiAuth",
|
26
|
+
"Because specified OpenID has already been registered, " +
|
27
|
+
"it is not possible to use it. ")]
|
26
28
|
else
|
27
29
|
session[:identity_url] = identity_url
|
28
30
|
redirect_to(:action => "authenticated")
|
@@ -14,7 +14,7 @@ class ActivationMailer < ActionMailer::Base
|
|
14
14
|
raise(ArgumentError) unless options.empty?
|
15
15
|
|
16
16
|
return {
|
17
|
-
:subject => SubjectPrefix + "
|
17
|
+
:subject => SubjectPrefix + p_("MultiAuth", "User registration"),
|
18
18
|
:from => FromAddress,
|
19
19
|
:recipients => recipients,
|
20
20
|
:body => {:activation_url => activation_url},
|
@@ -27,7 +27,7 @@ class ActivationMailer < ActionMailer::Base
|
|
27
27
|
raise(ArgumentError) unless options.empty?
|
28
28
|
|
29
29
|
return {
|
30
|
-
:subject => SubjectPrefix + "
|
30
|
+
:subject => SubjectPrefix + p_("MultiAuth", "User registration completed"),
|
31
31
|
:from => FromAddress,
|
32
32
|
:recipients => recipients,
|
33
33
|
:body => {},
|
@@ -41,7 +41,7 @@ class ActivationMailer < ActionMailer::Base
|
|
41
41
|
raise(ArgumentError) unless options.empty?
|
42
42
|
|
43
43
|
return {
|
44
|
-
:subject => SubjectPrefix + "
|
44
|
+
:subject => SubjectPrefix + p_("MultiAuth", "Email address registration for authentication"),
|
45
45
|
:from => FromAddress,
|
46
46
|
:recipients => recipients,
|
47
47
|
:body => {:activation_url => activation_url},
|
@@ -54,7 +54,7 @@ class ActivationMailer < ActionMailer::Base
|
|
54
54
|
raise(ArgumentError) unless options.empty?
|
55
55
|
|
56
56
|
return {
|
57
|
-
:subject => SubjectPrefix + "
|
57
|
+
:subject => SubjectPrefix + p_("MultiAuth", "Email address registration for authentication completed"),
|
58
58
|
:from => FromAddress,
|
59
59
|
:recipients => recipients,
|
60
60
|
:body => {},
|
@@ -68,7 +68,7 @@ class ActivationMailer < ActionMailer::Base
|
|
68
68
|
raise(ArgumentError) unless options.empty?
|
69
69
|
|
70
70
|
return {
|
71
|
-
:subject => SubjectPrefix + "
|
71
|
+
:subject => SubjectPrefix + p_("MultiAuth", "Email address registration for notification"),
|
72
72
|
:from => FromAddress,
|
73
73
|
:recipients => recipients,
|
74
74
|
:body => {:activation_url => activation_url},
|
@@ -81,7 +81,7 @@ class ActivationMailer < ActionMailer::Base
|
|
81
81
|
raise(ArgumentError) unless options.empty?
|
82
82
|
|
83
83
|
return {
|
84
|
-
:subject => SubjectPrefix + "
|
84
|
+
:subject => SubjectPrefix + p_("MultiAuth", "Email address registration for notification completed"),
|
85
85
|
:from => FromAddress,
|
86
86
|
:recipients => recipients,
|
87
87
|
:body => {},
|
@@ -16,6 +16,11 @@
|
|
16
16
|
|
17
17
|
# メール認証情報
|
18
18
|
class EmailCredential < ActiveRecord::Base
|
19
|
+
|
20
|
+
untranslate :created_at, :user_id, :hashed_password
|
21
|
+
|
22
|
+
N_("EmailCredential|Activated on")
|
23
|
+
|
19
24
|
EmailMaximumLength = 200
|
20
25
|
TokenLength = 20
|
21
26
|
TokenPattern = TokenUtil.create_token_regexp(TokenLength)
|
@@ -13,6 +13,11 @@
|
|
13
13
|
|
14
14
|
# OpenID認証情報
|
15
15
|
class OpenIdCredential < ActiveRecord::Base
|
16
|
+
|
17
|
+
untranslate :created_at, :user_id
|
18
|
+
|
19
|
+
N_("OpenIdCredential|Activated on")
|
20
|
+
|
16
21
|
MaximumRecordsPerUser = 10
|
17
22
|
|
18
23
|
belongs_to :user, :class_name => MultiAuth.user_model, :foreign_key => 'user_id'
|
data/app/models/session.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# == Schema Information
|
2
3
|
# Schema version: 20090529051529
|
3
4
|
#
|
@@ -12,6 +13,9 @@
|
|
12
13
|
|
13
14
|
# セッション
|
14
15
|
class Session < ActiveRecord::Base
|
16
|
+
|
17
|
+
untranslate_all
|
18
|
+
|
15
19
|
def self.cleanup(seconds)
|
16
20
|
self.delete_all(["(sessions.updated_at < ?)", Time.now - seconds])
|
17
21
|
return nil
|
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<%=p_("MultiAuth", "Email address for authentication will be registered.") %>
|
2
|
+
<%=p_("MultiAuth", "Registration is completed by accessing following URL.") %>
|
3
3
|
|
4
4
|
<%= @activation_url %>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
<%=p_("MultiAuth", "- For access with cellular phone etc.") %>
|
7
|
+
<%=p_("MultiAuth", "It is not possible to register from the cellular phone etc. that do not correspond to Cookie now.") %>
|
8
|
+
<%=p_("MultiAuth", "Please register after forwarding this mail to PC etc. though it is time.") %>
|
9
9
|
|
10
10
|
--
|
11
11
|
<%= MultiAuth.application_name %>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<%=p_("MultiAuth", "Email address for notification will be registered.") %>
|
2
|
+
<%=p_("MultiAuth", "Registration is completed by accessing following URL.") %>
|
3
3
|
|
4
4
|
<%= @activation_url %>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
<%=p_("MultiAuth", "- For access with cellular phone etc.") %>
|
7
|
+
<%=p_("MultiAuth", "It is not possible to register from the cellular phone etc. that do not correspond to Cookie now.") %>
|
8
|
+
<%=p_("MultiAuth", "Please register after forwarding this mail to PC etc. though it is time.") %>
|
9
9
|
|
10
10
|
--
|
11
11
|
<%= MultiAuth.application_name %>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<%= MultiAuth.application_name
|
2
|
-
|
1
|
+
<%=p_("MultiAuth", "Thank you for the user registration to %{app}." % { :app => MultiAuth.application_name }) %>
|
2
|
+
<%=p_("MultiAuth", "Registration is completed by accessing following URL.") %>
|
3
3
|
|
4
4
|
<%= @activation_url %>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
<%=p_("MultiAuth", "- For access with cellular phone etc.") %>
|
7
|
+
<%=p_("MultiAuth", "It is not possible to register from the cellular phone etc. that do not correspond to Cookie now.") %>
|
8
|
+
<%=p_("MultiAuth", "Please register after forwarding this mail to PC etc. though it is time.") %>
|
9
9
|
|
10
10
|
--
|
11
11
|
<%= MultiAuth.application_name %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
<%- @title = "
|
2
|
+
<%- @title = p_("MultiAuth", "Login") -%>
|
3
3
|
<%- @enable_side_column = false -%>
|
4
4
|
|
5
5
|
<%- additional_head { -%>
|
@@ -61,7 +61,7 @@
|
|
61
61
|
<%- } -%>
|
62
62
|
|
63
63
|
<div id="dialog">
|
64
|
-
<h1
|
64
|
+
<h1><%=h p_("MultiAuth", "Login") %></h1>
|
65
65
|
<%- form_for(:login_form, @login_form, :url => {:action => "login"}) do |f| -%>
|
66
66
|
<table id="email-login">
|
67
67
|
<tr>
|
@@ -79,7 +79,7 @@
|
|
79
79
|
</td>
|
80
80
|
</tr>
|
81
81
|
</table>
|
82
|
-
<%= submit_tag("
|
82
|
+
<%= submit_tag(p_("MultiAuth", "Login")) %>
|
83
83
|
<%- end -%>
|
84
84
|
</div>
|
85
85
|
|