Revision
336
Author
buchan
Date
2011-01-22 10:38:25 +0100 (Sat, 22 Jan 2011)

Log Message

Fix greeting in password reset key mail, by sending cn to stash
Also add some more error error checking on the search

Modified Paths

Modified: identity/CatDap/trunk/lib/CatDap/Controller/forgot_password.pm
===================================================================
--- identity/CatDap/trunk/lib/CatDap/Controller/forgot_password.pm	2011-01-22 08:52:05 UTC (rev 335)
+++ identity/CatDap/trunk/lib/CatDap/Controller/forgot_password.pm	2011-01-22 09:38:25 UTC (rev 336)
@@ -56,7 +56,10 @@
 	$emailfilter =~ s/\%s/$email/g,
 	$c->log->debug("Searching for email $email with filter $emailfilter");
 	my $mesg = $c->model('Proxy')->search($emailfilter);
-	if (!$mesg->entries()) {
+
+	$c->log->info(printf("Search failed: %s"),$mesg->error)	if ($mesg->code);
+	my @entries = $mesg->entries;
+	if (@entries != 1) {
 		push @errors,$c->loc(
 			'This email address is not bound to an account'
 		);
@@ -86,6 +89,7 @@
 			'template'	=> 'forgot_password.tt',
 		},
 		url => $c->uri_for('/forgot_password/confirm') . "?secret=$secret",
+		cn => @entries[0]->cn,
 	);
 
 	$c->log->info("Sending forgot password mail to email address $email");