[25869] users/jberry/mpwa
source_changes at macosforge.org
source_changes at macosforge.org
Sun Jun 3 22:44:55 PDT 2007
Revision: 25869
http://trac.macosforge.org/projects/macports/changeset/25869
Author: jberry at macports.org
Date: 2007-06-03 22:44:55 -0700 (Sun, 03 Jun 2007)
Log Message:
-----------
mpwa: in progress work to support user validation and registration
Modified Paths:
--------------
users/jberry/mpwa/app/controllers/person_controller.rb
users/jberry/mpwa/app/views/person/show.rhtml
users/jberry/mpwa/doc/TODO.txt
users/jberry/mpwa/doc/schema.sql
Added Paths:
-----------
users/jberry/mpwa/app/models/notifier.rb
users/jberry/mpwa/app/models/token.rb
users/jberry/mpwa/app/views/notifier/
users/jberry/mpwa/app/views/notifier/user_validation.rhtml
users/jberry/mpwa/test/fixtures/notifier/
users/jberry/mpwa/test/fixtures/tokens.yml
users/jberry/mpwa/test/unit/notifier_test.rb
users/jberry/mpwa/test/unit/token_test.rb
Modified: users/jberry/mpwa/app/controllers/person_controller.rb
===================================================================
--- users/jberry/mpwa/app/controllers/person_controller.rb 2007-06-04 05:44:12 UTC (rev 25868)
+++ users/jberry/mpwa/app/controllers/person_controller.rb 2007-06-04 05:44:55 UTC (rev 25869)
@@ -49,5 +49,20 @@
redirect_to :action => 'list'
end
+ def validation_request
+ @person = Person.find(params[:id])
+
+ # Check captcha result
+ if (params[:a].to_i + params[:b].to_i == params[:sum].to_i)
+ # Create token
+ token = Token.create(:type => 'validation', :random => rand(999999999), :expires => DateTime.now() + 1)
+ Notifier.deliver_user_validation(@person, token)
+ flash[:notice] = 'Validation email sent'
+ elsif
+ flash[:notice] = 'Incorrect sum'
+ end
+ redirect_to :action => 'show', :id => @person
+ end
+
private :create, :edit, :update, :destroy
end
Added: users/jberry/mpwa/app/models/notifier.rb
===================================================================
--- users/jberry/mpwa/app/models/notifier.rb (rev 0)
+++ users/jberry/mpwa/app/models/notifier.rb 2007-06-04 05:44:55 UTC (rev 25869)
@@ -0,0 +1,13 @@
+class Notifier < ActionMailer::Base
+
+ def user_validation(user, token)
+ # Email header info MUST be added here
+ recipients user.email
+ from "do_not_reply at macports.com"
+ subject "MacPorts user validation"
+
+ # Email body substitutions go here
+ body :user => user, :token -> token
+ end
+
+end
Added: users/jberry/mpwa/app/models/token.rb
===================================================================
--- users/jberry/mpwa/app/models/token.rb (rev 0)
+++ users/jberry/mpwa/app/models/token.rb 2007-06-04 05:44:55 UTC (rev 25869)
@@ -0,0 +1,2 @@
+class Token < ActiveRecord::Base
+end
Added: users/jberry/mpwa/app/views/notifier/user_validation.rhtml
===================================================================
--- users/jberry/mpwa/app/views/notifier/user_validation.rhtml (rev 0)
+++ users/jberry/mpwa/app/views/notifier/user_validation.rhtml 2007-06-04 05:44:55 UTC (rev 25869)
@@ -0,0 +1,5 @@
+Dear <%= @user.user_name %>,
+
+URL: <%= @token %>
+
+Your account will allow you to do blah, blah, blah.
\ No newline at end of file
Modified: users/jberry/mpwa/app/views/person/show.rhtml
===================================================================
--- users/jberry/mpwa/app/views/person/show.rhtml 2007-06-04 05:44:12 UTC (rev 25868)
+++ users/jberry/mpwa/app/views/person/show.rhtml 2007-06-04 05:44:55 UTC (rev 25869)
@@ -36,3 +36,18 @@
</tr>
<% end %>
</table>
+
+<!--
+<h4>Validation</h4>
+<form action='/person/validation_request' method='post'>
+ <p>To request an email validation token, you must first pass this simple test:</p>
+ <p>What is the <tt>sum</tt> of <tt><%= a=rand(10)%></tt> and <tt><%= b=rand(10)%></tt>?
+ <input type='text' name='sum' size='4'></input>
+ <input type='hidden' name='id' value='<%=@person.id%>'></input>
+ <input type='hidden' name='a' value='<%=a%>'></input>
+ <input type='hidden' name='b' value='<%=b%>'></input>
+ </p>
+ <input type='submit' name='validation_request' value='Send Validation Email'>
+
+</form>
+-->
Modified: users/jberry/mpwa/doc/TODO.txt
===================================================================
--- users/jberry/mpwa/doc/TODO.txt 2007-06-04 05:44:12 UTC (rev 25868)
+++ users/jberry/mpwa/doc/TODO.txt 2007-06-04 05:44:55 UTC (rev 25869)
@@ -1,26 +1,38 @@
Short Term:
- - Improve ui
- - Make latest/greatest port version more visible
+ - Add user login/authentication/pubkey support
+ - Add commentability
+ - Add status reports
+
+Mid Term:
+ - "port comment"
+ - "port report"
+ - "port reports"
+ - "port comments"
+
+Needed Schema Changes:
+
+Potentials:
+
- Additional Search options:
- Portname vs. partial portname? (Currently searches partial portname).
- Search port descriptions in addition to port names.
-
-Needed Schema Changes:
+ - Make latest/greatest port version more visible
-UI Design Thoughts:
- - Global Page header:
- - MacPorts logo
- - Search Box to search for ports by name
- - Category tags
-
- - Top level page:
- - Well-known tags
- - Link to all tags page?
-
- - Tag page:
- - Alphabetical listing of ports by tag
- - Some listing of portpkgs by tag?
-
- - Port Page
\ No newline at end of file
+User Authentication/Registration:
+
+ - Existing users may request validation by clicking a "validateme" link,
+ which will send them an email with a special token allowing them to
+ enter identifying information, etc.
+
+ - New users request registration in much the same way: by entering their
+ email address (which creates a record for them) and responding to the
+ validation email.
+
+ - Any user must pass some sort of captcha test in addition to entering
+ a pass phrase to be able to login and complete registration.
+
+ - User profile includes their public key, email address, login name,
+ and first and last name
+
\ No newline at end of file
Modified: users/jberry/mpwa/doc/schema.sql
===================================================================
--- users/jberry/mpwa/doc/schema.sql 2007-06-04 05:44:12 UTC (rev 25868)
+++ users/jberry/mpwa/doc/schema.sql 2007-06-04 05:44:55 UTC (rev 25869)
@@ -250,6 +250,16 @@
);
+-- general purpose token
+drop table if exists tokens;
+create table tokens (
+ id bigint not null primary key auto_increment,
+ random bigint not null,
+ expires datetime,
+ data text,
+ type varchar(15)
+);
+
-- Missing components:
-- ==================================
Added: users/jberry/mpwa/test/fixtures/tokens.yml
===================================================================
--- users/jberry/mpwa/test/fixtures/tokens.yml (rev 0)
+++ users/jberry/mpwa/test/fixtures/tokens.yml 2007-06-04 05:44:55 UTC (rev 25869)
@@ -0,0 +1,5 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+ id: 1
+two:
+ id: 2
Added: users/jberry/mpwa/test/unit/notifier_test.rb
===================================================================
--- users/jberry/mpwa/test/unit/notifier_test.rb (rev 0)
+++ users/jberry/mpwa/test/unit/notifier_test.rb 2007-06-04 05:44:55 UTC (rev 25869)
@@ -0,0 +1,27 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class NotifierTest < Test::Unit::TestCase
+ FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
+ CHARSET = "utf-8"
+
+ include ActionMailer::Quoting
+
+ def setup
+ ActionMailer::Base.delivery_method = :test
+ ActionMailer::Base.perform_deliveries = true
+ ActionMailer::Base.deliveries = []
+
+ @expected = TMail::Mail.new
+ @expected.set_content_type "text", "plain", { "charset" => CHARSET }
+ @expected.mime_version = '1.0'
+ end
+
+ private
+ def read_fixture(action)
+ IO.readlines("#{FIXTURES_PATH}/notifier/#{action}")
+ end
+
+ def encode(subject)
+ quoted_printable(subject, CHARSET)
+ end
+end
Added: users/jberry/mpwa/test/unit/token_test.rb
===================================================================
--- users/jberry/mpwa/test/unit/token_test.rb (rev 0)
+++ users/jberry/mpwa/test/unit/token_test.rb 2007-06-04 05:44:55 UTC (rev 25869)
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class TokenTest < Test::Unit::TestCase
+ fixtures :tokens
+
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070603/82a075ce/attachment.html
More information about the macports-changes
mailing list