[mb-commits] r9875 - in mb_server/branches/TemplateToolkit: lib/MusicBrainz/Server/Controller root/forms/user root/layout/sidebar
root at musicbrainz.org
root at musicbrainz.org
Fri Jun 20 17:04:46 UTC 2008
Author: acid2
Date: 2008-06-20 17:04:46 +0000 (Fri, 20 Jun 2008)
New Revision: 9875
Modified:
mb_server/branches/TemplateToolkit/lib/MusicBrainz/Server/Controller/User.pm
mb_server/branches/TemplateToolkit/root/forms/user/register.fb
mb_server/branches/TemplateToolkit/root/layout/sidebar/login.tt
Log:
Create users if they fill in the form. Still working out how to correctly add custom validation to formbuilder (like username already taken)
Modified: mb_server/branches/TemplateToolkit/lib/MusicBrainz/Server/Controller/User.pm
===================================================================
--- mb_server/branches/TemplateToolkit/lib/MusicBrainz/Server/Controller/User.pm 2008-06-20 16:19:17 UTC (rev 9874)
+++ mb_server/branches/TemplateToolkit/lib/MusicBrainz/Server/Controller/User.pm 2008-06-20 17:04:46 UTC (rev 9875)
@@ -84,11 +84,31 @@
if($c->form->submitted && $c->form->validate)
{
- }
- else
- {
+ require MusicBrainz;
+ require UserStuff;
+
+ my $mb = new MusicBrainz;
+ $mb->Login();
+
+ my $ui = UserStuff->new($mb->{DBH});
+ my ($userobj, $createlogin) = $ui->CreateLogin($c->form->field('username'),
+ $c->form->field('password'),
+ $c->form->field('confirm_password'));
+
+ # if createlogin list is empty, the user was created.
+ if (@$createlogin == 0)
+ {
+ $c->error(":)");
+ }
+ else
+ {
+ $c->error(":(");
+ }
+
$c->stash->{template} = 'user/register.tt';
}
+
+ $c->stash->{template} = 'user/register.tt';
}
=head2 profile
Modified: mb_server/branches/TemplateToolkit/root/forms/user/register.fb
===================================================================
--- mb_server/branches/TemplateToolkit/root/forms/user/register.fb 2008-06-20 16:19:17 UTC (rev 9874)
+++ mb_server/branches/TemplateToolkit/root/forms/user/register.fb 2008-06-20 17:04:46 UTC (rev 9875)
@@ -24,5 +24,4 @@
validate:
confirm_password:
- javascript: == form.password.value
perl: eq $form->field("password")
\ No newline at end of file
Modified: mb_server/branches/TemplateToolkit/root/layout/sidebar/login.tt
===================================================================
--- mb_server/branches/TemplateToolkit/root/layout/sidebar/login.tt 2008-06-20 16:19:17 UTC (rev 9874)
+++ mb_server/branches/TemplateToolkit/root/layout/sidebar/login.tt 2008-06-20 17:04:46 UTC (rev 9875)
@@ -1,6 +1,6 @@
<ul>
<li><a href="[% c.uri_for('/user/login') %]">Login</a></li>
- <li><a href="/bad_link">Register</a></li>
+ <li><a href="[% c.uri_for('/user/register') %]">Register</a></li>
<li><a href="/bad_link">Forgot Password</a></li>
<li><a href="/bad_link">Donate!</a></li>
</ul>
More information about the MusicBrainz-commits
mailing list