[vhffs-dev] [1295] The user creation robot used to generate a random password, this is no longer the case.

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1295
Author:   gradator
Date:     2008-10-29 03:49:15 +0100 (Wed, 29 Oct 2008)

Log Message:
-----------
The user creation robot used to generate a random password, this is no longer the case.

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Robots/User.pm
    trunk/vhffs-api/src/Vhffs/User.pm
    trunk/vhffs-api/src/examples/generate_password.pl
    trunk/vhffs-panel/lost_ack.pl


Modified: trunk/vhffs-api/src/Vhffs/Robots/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/User.pm	2008-10-26 16:58:14 UTC (rev 1294)
+++ trunk/vhffs-api/src/Vhffs/Robots/User.pm	2008-10-29 02:49:15 UTC (rev 1295)
@@ -93,12 +93,9 @@
 		$user->set_status( Vhffs::Constants::ACTIVATED );
 		return -1 if( $user->commit < 0 );
 
-		# Send a mail with plain password inside
-		my $plainpassword = $user->generate_password;
-		my $subject = "Welcome on VHFFS";
-		my $content = sprintf("Hello %s %s, Welcome on VHFFS\n\nHere are your login information :\nUser: %s\nPassword: %s\n\nVHFFS Administrators\n", $user->get_firstname, $user->get_lastname, $user->get_username, $plainpassword );
+		my $subject = sprintf("Account created on %s", $main->get_config->get_host_name );
+		my $content = sprintf("Hello %s %s,\n\nWe are pleased to announce that your account is now fully created on\n%s.\nYou can now login on the panel.\n\n%s Administrators\n", $user->get_firstname, $user->get_lastname, $main->get_config->get_host_name, $main->get_config->get_host_name );
 		$user->send_mail_user( $subject, $content );
-
 	}
 	else  {
 		$user->add_history( 'cannot create the homedir directory' );

Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm	2008-10-26 16:58:14 UTC (rev 1294)
+++ trunk/vhffs-api/src/Vhffs/User.pm	2008-10-29 02:49:15 UTC (rev 1295)
@@ -194,6 +194,7 @@
 
         # Insert base information
         $admin = 0 unless (defined $admin);
+        $password = Vhffs::Functions::generate_random_password if( not defined $password or $password eq '' );
         my $homedir = Vhffs::Functions::hash_homename( $username  , $main );
 
         my $sth = $dbh->prepare('INSERT INTO vhffs_users (uid, gid, username, shell, passwd, homedir, admin, firstname, lastname, address, zipcode, city, country, mail, gpg_key, note, language, theme, lastloginpanel, object_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, NULL, NULL, ?)');
@@ -209,13 +210,18 @@
         $user = get_by_uid($main, $uid);
     };
 
-    if($@) {
-        warn "Error creating user : $@\n";
-        $dbh->rollback;
-        undef $user;
-    }
+	if($@) {
+		warn "Error creating user : $@\n";
+		$dbh->rollback;
+		undef $user;
+	}
+	else {
+		my $subject = sprintf("Welcome on %s", $main->get_config->get_host_name );
+		my $content = sprintf("Hello %s %s, Welcome on %s\n\nHere are your login information :\nUser: %s\nPassword: %s\n\nYour account is NOT created yet, you cannot login on the panel now, you\nare going to receive another mail in a few minutes upon account creation.\n\n%s Administrators\n", $user->get_firstname, $user->get_lastname, $main->get_config->get_host_name, $user->get_username, $password , $main->get_config->get_host_name );
+		$user->send_mail_user( $subject, $content );
+	}
 
-    return $user;
+	return $user;
 }
 
 #modify a user
@@ -387,19 +393,6 @@
 }
 
 
-sub generate_password
-{
-	use Vhffs::Functions;
-	my $user = shift;
-
-	my $password = generate_random_password Vhffs::Functions;
-	$user->set_password( $password );
-	$user->commit;
-
-	return $password;
-}
-
-
 #
 # Some accessors
 ################

Modified: trunk/vhffs-api/src/examples/generate_password.pl
===================================================================
--- trunk/vhffs-api/src/examples/generate_password.pl	2008-10-26 16:58:14 UTC (rev 1294)
+++ trunk/vhffs-api/src/examples/generate_password.pl	2008-10-29 02:49:15 UTC (rev 1295)
@@ -1,5 +1,6 @@
 #!%PERL% -w
 
+# -- OBSOLETE -- OBSOLETE -- OBSOLETE -- OBSOLETE -- OBSOLETE -- OBSOLETE --
 
 use strict;
 

Modified: trunk/vhffs-panel/lost_ack.pl
===================================================================
--- trunk/vhffs-panel/lost_ack.pl	2008-10-26 16:58:14 UTC (rev 1294)
+++ trunk/vhffs-panel/lost_ack.pl	2008-10-29 02:49:15 UTC (rev 1295)
@@ -44,6 +44,7 @@
 use Vhffs::Main;
 use Vhffs::Panel::Main;
 use Vhffs::Services::MailUser;
+use Vhffs::Functions;
 
 my $panel = new Vhffs::Panel::Main();
 exit 0 unless $panel;
@@ -58,15 +59,17 @@
 if ( defined $user && $user->{'state'} == Vhffs::Constants::ACTIVATED )
 {
     #create a new password for this user
-    my $plainpassword = $user->generate_password;
+    my $password = Vhffs::Functions::generate_random_password;
+    $user->set_password( $password );
+    $user->commit;
     my $mu = init Vhffs::Services::MailUser( $vhffs , $user );
     if( defined $mu  &&  $mu->exists_box) {
-        $mu->changepassword( $plainpassword );
+        $mu->changepassword( $password );
     } 
   
     # Send a mail with plain password inside
-    my $subject = "Password changed";
-    my $content = sprintf("Hello %s %s,\n\nYou asked for a new password, here are your new login information:\nUser: %s\nPassword: %s\n\nVHFFS Administrators\n", $user->get_firstname, $user->get_lastname, $user->get_username, $plainpassword );
+    my $subject = sprintf("Password changed on %s", $vhffs->get_config->get_host_name );
+    my $content = sprintf("Hello %s %s,\n\nYou asked for a new password, here are your new login information:\nUser: %s\nPassword: %s\n\n%s Administrators\n", $user->get_firstname, $user->get_lastname, $user->get_username, $password , $vhffs->get_config->get_host_name );
     $user->send_mail_user( $subject, $content );
     
     $template = new HTML::Template( filename => $templatedir."/panel/main/lost_ok.tmpl" );


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/