ae_users_legacy 0.6.11 → 0.6.12

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -23,9 +23,6 @@ update accounts, people set accounts.person_id=people.id
23
23
  where accounts.id = people.account_id;
24
24
  alter table people drop column account_id;
25
25
 
26
- create table open_id_identities (id int not null auto_increment primary key,
27
- person_id int, identity_url varchar(4000));
28
-
29
26
  You'll also want to run this command in each of your application databases:
30
27
 
31
28
  create table auth_tickets (id int not null auto_increment primary key,
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
- gem.version = "0.6.11"
3
+ gem.version = "0.6.12"
4
4
 
5
5
  gem.authors = ["Nat Budin"]
6
6
  gem.email = ["natbudin@gmail.com"]
@@ -15,5 +15,4 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
 
17
17
  gem.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
18
- gem.add_runtime_dependency(%q<ruby-openid>, [">= 2.0.4"])
19
18
  end
@@ -1,6 +1,6 @@
1
1
  class AccountController < ApplicationController
2
2
  unloadable
3
- require_login :only => [:edit_profile, :edit_email_addresses, :change_password, :add_openid, :delete_openid]
3
+ require_login :only => [:edit_profile, :edit_email_addresses, :change_password]
4
4
  before_filter :check_signup_allowed, :only => [:signup, :signup_success]
5
5
 
6
6
  filter_parameter_logging :password
@@ -107,48 +107,6 @@ class AccountController < ApplicationController
107
107
  def signup_success
108
108
  end
109
109
 
110
- def add_openid
111
- if using_open_id?
112
- authenticate_with_open_id(params[:openid_url]) do |result, identity_url|
113
- if result.successful?
114
- id = OpenIdIdentity.find_by_identity_url(identity_url)
115
- if id.nil?
116
- id = OpenIdIdentity.new :person => logged_in_person, :identity_url => identity_url
117
- else
118
- if id.person.nil?
119
- id.person = logged_in_person
120
- elsif id.person != logged_in_person
121
- flash[:error_messages] = ["That OpenID belongs to a different person (#{id.person.name})."]
122
- return
123
- end
124
- end
125
- if not id.save
126
- flash[:error_messages] = id.errors.collect { |e| e[0].humanize + " " + e[1] }
127
- end
128
- else
129
- flash[:error_messages] = [result.message]
130
- end
131
- redirect_to :action => 'edit_profile'
132
- end
133
- else
134
- flash[:error_messages] = ["Please enter an OpenID url."]
135
- end
136
- end
137
-
138
- def delete_openid
139
- id = OpenIdIdentity.find(params[:id])
140
- if id.person == logged_in_person
141
- if logged_in_person.account or logged_in_person.open_id_identities.length > 1
142
- id.destroy
143
- else
144
- flash[:error_messages] = ["Deleting that OpenID would leave you no way of logging in!"]
145
- end
146
- else
147
- flash[:error_messages] = ["That OpenID does not belong to you!"]
148
- end
149
- redirect_to :action => 'edit_profile'
150
- end
151
-
152
110
  def signup
153
111
  ret = create_account_and_person()
154
112
  if ret == :success
@@ -1,7 +1,7 @@
1
1
  class AuthController < ApplicationController
2
2
  unloadable
3
3
  filter_parameter_logging :password
4
- before_filter :construct_login, :only => [:login, :openid_login, :forgot_form]
4
+ before_filter :construct_login, :only => [:login, :forgot_form]
5
5
 
6
6
  def index
7
7
  respond_to do |format|
@@ -9,15 +9,6 @@ class AuthController < ApplicationController
9
9
  end
10
10
  end
11
11
 
12
- def openid_login
13
- params[:openid_url] ||= cookies['openid_url']
14
- if using_open_id?
15
- if attempt_open_id_login(@login.return_to)
16
- successful_login_redirect
17
- end
18
- end
19
- end
20
-
21
12
  def login
22
13
  if request.post?
23
14
  unless @login.password or @login.have_password
@@ -31,75 +22,6 @@ class AuthController < ApplicationController
31
22
  end
32
23
  end
33
24
  end
34
-
35
- def needs_person
36
- @open_id_identity = OpenIdIdentity.find_or_create_by_identity_url(session[:identity_url])
37
- @person = Person.new
38
- if not AeUsers.profile_class.nil?
39
- @app_profile = AeUsers.profile_class.send(:new, :person => @person)
40
- end
41
-
42
- if params[:registration]
43
- person_map = HashWithIndifferentAccess.new(Person.sreg_map)
44
- profile_map = if AeUsers.profile_class and AeUsers.profile_class.respond_to?("sreg_map")
45
- HashWithIndifferentAccess.new(AeUsers.profile_class.sreg_map)
46
- else
47
- nil
48
- end
49
-
50
- params[:registration].each_pair do |key, value|
51
- if key == 'email'
52
- params[:email] = value
53
- elsif person_map.has_key?(key.to_s)
54
- mapper = person_map[key]
55
- attrs = mapper.call(value)
56
- @person.attributes = attrs
57
- elsif (profile_map and profile_map.has_key?(key))
58
- mapper = profile_map[key]
59
- @app_profile.attributes = mapper.call(value)
60
- end
61
- end
62
- end
63
- if params[:person]
64
- @person.attributes = params[:person]
65
- end
66
- if params[:app_profile] and @app_profile
67
- @app_profile.attributes = params[:app_profile]
68
- end
69
-
70
- if request.post?
71
- error_messages = []
72
- error_fields = []
73
-
74
- ["firstname", "lastname", "gender"].each do |field|
75
- if not @person.send(field)
76
- error_fields.push field
77
- error_messages.push "You must enter a value for #{field}."
78
- end
79
- end
80
-
81
- if not params[:email]
82
- error_fields.push("email")
83
- error_messages.push "You must enter a value for email."
84
- end
85
-
86
- if error_messages.length > 0
87
- flash[:error_fields] = error_fields
88
- flash[:error_messages] = error_messages
89
- else
90
- @person.save
91
- @person.primary_email_address = params[:email]
92
- @open_id_identity.person = @person
93
- @open_id_identity.save
94
- if @app_profile
95
- @app_profile.save
96
- end
97
-
98
- session[:person] = @person
99
- redirect_to session[:return_to]
100
- end
101
- end
102
- end
103
25
 
104
26
  def auth_form
105
27
  respond_to do |format|
data/app/models/person.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  class Person < ActiveRecord::Base
2
2
  establish_connection :users
3
3
  has_one :account
4
- has_many :open_id_identities
5
4
  has_and_belongs_to_many :roles
6
5
  has_many :permissions, :dependent => :destroy, :include => :permissioned
7
6
  has_many :email_addresses, :dependent => :destroy
@@ -34,31 +34,6 @@ form {
34
34
  <% end %>
35
35
  <% end -%>
36
36
 
37
- <h2>OpenID Identities</h2>
38
-
39
- <p>OpenID is a free and easy way to use a single digital identity across the Internet. For more information,
40
- <%= link_to "visit the OpenID web site", "http://www.openid.net" %>.</p>
41
-
42
- <table>
43
- <% @person.open_id_identities.each do |id| -%>
44
- <tr>
45
- <td></td>
46
- <td>
47
- <%= image_tag "ae_users/openid.gif" %>
48
- <i><%=h id.identity_url %></i>
49
- </td>
50
- <td><%= button_to "Delete", {:action => "delete_openid", :id => id.id}, {:confirm => "Are you sure you wish to remove this OpenID?"} %></td>
51
- </tr>
52
- <% end -%>
53
- <tr>
54
- <% form_for("add_openid", nil, :url => {:action => "add_openid"}) do |f| -%>
55
- <td>Add new OpenID:</td>
56
- <td><%= text_field_tag "openid_url", @openid_url, :style => "background: #FFFFFF url('#{image_path "ae_users/openid.gif"}') no-repeat scroll 0pt 50%; padding-left: 18px; width: 60%;" %></td>
57
- <td><%= submit_tag "Add" %></td>
58
- <% end -%>
59
- </tr>
60
- </table>
61
-
62
37
  <% form_for("email_addresses", nil, :url => {:action => 'edit_email_addresses'},
63
38
  :html => {:id => 'edit_email_addresses_form'}) do |f| %>
64
39
 
@@ -114,4 +89,4 @@ form {
114
89
  <% else -%>
115
90
  <%= submit_tag "Edit profile" %>
116
91
  <% end -%>
117
- <% end %>
92
+ <% end %>
@@ -4,7 +4,7 @@
4
4
  :html => {:class => 'auth_form'} ) do |f| -%>
5
5
  <% if not logged_in? %>
6
6
  <script type="text/javascript" src="<%=url_for :controller => 'auth', :action => "auth_form",
7
- :format => "js", :openid_url => params[:openid_url] %>"></script>
7
+ :format => "js" %>"></script>
8
8
 
9
9
  <%= f.hidden_field "return_to" %>
10
10
 
@@ -51,4 +51,4 @@
51
51
  </p>
52
52
  </div>
53
53
  <% end %>
54
- <% end -%>
54
+ <% end -%>
@@ -5,20 +5,5 @@
5
5
  <%= link_to "I forgot my password", :controller => "auth", :action => "forgot_form" %>
6
6
  </li>
7
7
  <% end -%>
8
- <% if params[:action] == "openid_login" -%>
9
- <li>
10
- <%= link_to "What's OpenID?", "http://www.openid.net", :target => "_blank" %>
11
- </li>
12
- <% end -%>
13
- <% unless params[:action] == "openid_login" -%>
14
- <li>
15
- <%= link_to "Log in with OpenID", :controller => "auth", :action => "openid_login", :return_to => @login.return_to %>
16
- </li>
17
- <% end -%>
18
- <% unless params[:action] == "login" -%>
19
- <li>
20
- <%= link_to "Log in with a password", :controller => "auth", :action => "login", :return_to => @login.return_to %>
21
- </li>
22
- <% end -%>
23
8
  </ul>
24
- <% end -%>
9
+ <% end -%>
@@ -12,12 +12,4 @@
12
12
  margin-left: -0.5em;
13
13
  font-weight: bold;
14
14
  display: block;
15
- }
16
- #openid_url {
17
- background-color: #fff;
18
- background-image: url(<%= image_path "ae_users/openid.gif" %>);
19
- background-position: left;
20
- background-repeat: no-repeat;
21
- padding-left: 18px;
22
- width: 90%;
23
15
  }
@@ -9,6 +9,5 @@ Example:
9
9
  public/images/ae_users/admin.png
10
10
  public/images/ae_users/group.png
11
11
  public/images/ae_users/logout.png
12
- public/images/ae_users/openid.gif
13
12
  public/images/ae_users/remove.png
14
13
  public/images/ae_users/user.png
@@ -5,7 +5,6 @@ class AeUsersGenerator < Rails::Generator::Base
5
5
  %w{add admin group logout remove user}.each do |img|
6
6
  m.file "#{img}.png", "public/images/ae_users/#{img}.png"
7
7
  end
8
- m.file "openid.gif", "public/images/ae_users/openid.gif"
9
8
  m.migration_template 'migration.rb', "db/migrate", :migration_file_name => 'ae_users_local_tables'
10
9
  end
11
10
  end
data/lib/ae_users.rb CHANGED
@@ -62,10 +62,6 @@ module AeUsers
62
62
  END_FUNC
63
63
  end
64
64
 
65
- def self.map_openid(map)
66
- map.open_id_complete 'auth', :controller => "auth", :action => "login", :requirements => { :method => :get }
67
- end
68
-
69
65
  class PermissionCache
70
66
  def initialize
71
67
  @cache = {}
@@ -342,53 +338,6 @@ module AeUsers
342
338
  end
343
339
  end
344
340
 
345
- def attempt_open_id_login(return_to)
346
- if return_to
347
- session[:return_to] = return_to
348
- else
349
- return_to = session[:return_to]
350
- end
351
-
352
- openid_url = params[:openid_url]
353
- params.delete(:openid_url)
354
-
355
- optional_fields = Person.sreg_map.keys
356
- if AeUsers.profile_class and AeUsers.profile_class.respond_to?('sreg_map')
357
- optional_fields += AeUsers.profile_class.sreg_map.keys
358
- end
359
- authenticate_with_open_id(openid_url, :optional => optional_fields) do |result, identity_url, registration|
360
- if result.successful?
361
- id = OpenIdIdentity.find_by_identity_url(identity_url)
362
- if not id.nil?
363
- @person = id.person
364
- end
365
- if id.nil? or @person.nil?
366
- if AeUsers.signup_allowed?
367
- session[:identity_url] = identity_url
368
- redirect_to :controller => 'auth', :action => :needs_person, :return_to => return_to, :registration => registration.data
369
- return false
370
- else
371
- flash[:error_messages] = ["Sorry, you are not registered with this site."]
372
- return false
373
- end
374
- else
375
- if (not AeUsers.profile_class.nil? and AeUsers.profile_class.find_by_person_id(@person.id).nil?)
376
- session[:provisional_person] = @person.id
377
- redirect_to :controller => 'auth', :action => :needs_profile, :return_to => return_to
378
- return false
379
- else
380
- session[:person] = @person.id
381
- return true
382
- end
383
- end
384
- else
385
- flash[:error_messages] = result.message
386
- return false
387
- end
388
- end
389
- return session[:person]
390
- end
391
-
392
341
  def attempt_ticket_login(secret)
393
342
  t = AuthTicket.find_ticket(secret)
394
343
  if t.nil?
@@ -406,8 +355,6 @@ module AeUsers
406
355
  if not params[:ae_email].blank? and not params[:ae_password].blank?
407
356
  login = Login.new(:email => params[:ae_email], :password => params[:ae_password], :return_to => return_to)
408
357
  attempt_login(login)
409
- elsif not params[:openid_url].blank?
410
- attempt_open_id_login(return_to)
411
358
  elsif not params[:ae_ticket].blank?
412
359
  attempt_ticket_login(params[:ae_ticket])
413
360
  end
data/schema.sql CHANGED
@@ -19,13 +19,6 @@ CREATE TABLE `email_addresses` (
19
19
  PRIMARY KEY (`id`)
20
20
  ) ENGINE=InnoDB AUTO_INCREMENT=791 DEFAULT CHARSET=latin1;
21
21
 
22
- CREATE TABLE `open_id_identities` (
23
- `id` int(11) NOT NULL AUTO_INCREMENT,
24
- `person_id` int(11) DEFAULT NULL,
25
- `identity_url` varchar(4000) DEFAULT NULL,
26
- PRIMARY KEY (`id`)
27
- ) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1;
28
-
29
22
  CREATE TABLE `people` (
30
23
  `id` int(11) NOT NULL AUTO_INCREMENT,
31
24
  `firstname` varchar(255) DEFAULT NULL,
metadata CHANGED
@@ -1,55 +1,44 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ae_users_legacy
3
- version: !ruby/object:Gem::Version
4
- version: 0.6.11
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 6
8
+ - 12
9
+ version: 0.6.12
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Nat Budin
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2012-06-29 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2012-10-15 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: thoughtbot-shoulda
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: ruby-openid
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: 2.0.4
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: 2.0.4
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :development
31
+ version_requirements: *id001
46
32
  description: Don't use this gem. Use something written in the last couple years instead.
47
- email:
33
+ email:
48
34
  - natbudin@gmail.com
49
35
  executables: []
36
+
50
37
  extensions: []
38
+
51
39
  extra_rdoc_files: []
52
- files:
40
+
41
+ files:
53
42
  - .gitignore
54
43
  - Gemfile
55
44
  - LICENSE
@@ -68,7 +57,6 @@ files:
68
57
  - app/models/auth_ticket.rb
69
58
  - app/models/email_address.rb
70
59
  - app/models/login.rb
71
- - app/models/open_id_identity.rb
72
60
  - app/models/permission.rb
73
61
  - app/models/person.rb
74
62
  - app/models/role.rb
@@ -85,7 +73,6 @@ files:
85
73
  - app/views/auth/_auth_form.rhtml
86
74
  - app/views/auth/_forgot_form.html.erb
87
75
  - app/views/auth/_mini_auth_form.rhtml
88
- - app/views/auth/_openid_auth_form.html.erb
89
76
  - app/views/auth/_other_login_options.html.erb
90
77
  - app/views/auth/auth_form.js.erb
91
78
  - app/views/auth/forgot.rhtml
@@ -93,9 +80,7 @@ files:
93
80
  - app/views/auth/index.css.erb
94
81
  - app/views/auth/login.rhtml
95
82
  - app/views/auth/needs_activation.rhtml
96
- - app/views/auth/needs_person.html.erb
97
83
  - app/views/auth/needs_profile.rhtml
98
- - app/views/auth/openid_login.html.erb
99
84
  - app/views/auth/resend_activation.rhtml
100
85
  - app/views/auth_notifier/account_activation.rhtml
101
86
  - app/views/auth_notifier/generated_password.rhtml
@@ -134,29 +119,35 @@ files:
134
119
  - tasks/ae_users_tasks.rake
135
120
  - test/ae_users_test.rb
136
121
  - uninstall.rb
137
- homepage: ''
122
+ has_rdoc: true
123
+ homepage: ""
138
124
  licenses: []
125
+
139
126
  post_install_message:
140
127
  rdoc_options: []
141
- require_paths:
128
+
129
+ require_paths:
142
130
  - lib
143
- required_ruby_version: !ruby/object:Gem::Requirement
144
- none: false
145
- requirements:
146
- - - ! '>='
147
- - !ruby/object:Gem::Version
148
- version: '0'
149
- required_rubygems_version: !ruby/object:Gem::Requirement
150
- none: false
151
- requirements:
152
- - - ! '>='
153
- - !ruby/object:Gem::Version
154
- version: '0'
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ segments:
136
+ - 0
137
+ version: "0"
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ segments:
143
+ - 0
144
+ version: "0"
155
145
  requirements: []
146
+
156
147
  rubyforge_project:
157
- rubygems_version: 1.8.23
148
+ rubygems_version: 1.3.6
158
149
  signing_key:
159
150
  specification_version: 3
160
151
  summary: An obsolete authentication and authorization system which you shouldn't use.
161
- test_files:
152
+ test_files:
162
153
  - test/ae_users_test.rb
@@ -1,5 +0,0 @@
1
- class OpenIdIdentity < ActiveRecord::Base
2
- establish_connection :users
3
- belongs_to :person
4
- validates_uniqueness_of :identity_url
5
- end
@@ -1,14 +0,0 @@
1
- <%= auth_stylesheet %>
2
-
3
- <% form_for('login', @login, :url => {:action => 'openid_login', :controller => 'auth'},
4
- :html => {:class => 'auth_form'} ) do |f| -%>
5
-
6
- <%= f.hidden_field "return_to" %>
7
-
8
- <label for="openid_url" class="block">OpenID</label>
9
- <%= text_field_tag "openid_url" %>
10
-
11
- <p style="text-align: center;">
12
- <%= submit_tag "Log in with OpenID", :style => "width: 50%; display: inline" %>
13
- </p>
14
- <% end -%>
@@ -1,32 +0,0 @@
1
- <h2>Welcome!</h2>
2
-
3
- <p>This is the first time you've visited this site. We just need a few pieces of information
4
- from you before we can log you in. We've attempted to get as much of it as possible from your
5
- OpenID provider, but some of it may be missing and/or incorrect. Please check the following form
6
- before pressing "Save changes" below.</p>
7
-
8
- <%= auth_stylesheet %>
9
-
10
- <% form_for("person", @person, :url => {:action => 'needs_person'},
11
- :html => {:id => 'edit_profile_form', :style => "max-width: 800px;"}) do |f| %>
12
- <%= hidden_field_tag "return_to", params[:return_to] %>
13
- <%= render :partial => 'account/personal_info', :locals => {:f => f} %>
14
-
15
- <p>
16
- <label for="email" class="block">Email:</label>
17
- <%= text_field_tag "email", params[:email] %>
18
- </p>
19
-
20
- <% if @app_profile -%>
21
-
22
- <% form_for("app_profile", @app_profile) do |profile_form| %>
23
- <%= render :partial => "account/#{@app_profile.class.name.tableize.singularize}",
24
- :locals => {:f => profile_form}%>
25
- <label></label>
26
- <%= submit_tag %>
27
- <% end %>
28
- <% else -%>
29
- <label></label>
30
- <%= submit_tag %>
31
- <% end -%>
32
- <% end %>
@@ -1,6 +0,0 @@
1
- <div id="openid_login">
2
- <h2>Log in with OpenID</h2>
3
- <%= render :partial => 'openid_auth_form' %>
4
- </div>
5
-
6
- <%= render :partial => "other_login_options" %>