generate a SIP password if it is blank
authorivan <ivan>
Mon, 21 Jul 2008 10:42:29 +0000 (10:42 +0000)
committerivan <ivan>
Mon, 21 Jul 2008 10:42:29 +0000 (10:42 +0000)
FS/FS/svc_phone.pm

index 04d5960..f7a4489 100644 (file)
@@ -1,12 +1,15 @@
 package FS::svc_phone;
 
 use strict;
-use vars qw( @ISA );
+use vars qw( @ISA @pw_set );
 #use FS::Record qw( qsearch qsearchs );
 use FS::svc_Common;
 
 @ISA = qw( FS::svc_Common );
 
+#avoid l 1 and o O 0
+@pw_set = ( 'a'..'k', 'm','n', 'p-z', 'A'..'N', 'P'..'Z' , '2'..'9' );
+
 =head1 NAME
 
 FS::svc_phone - Object methods for svc_phone records
@@ -184,6 +187,14 @@ sub check {
 
   $self->countrycode(1) unless $self->countrycode;
 
+  unless ( length($self->sip_password) ) {
+
+    $self->sip_password(
+      join('', map $pw_set[ int(rand $#pw_set) ], (0..16) )
+    );
+
+  }
+
   $self->SUPER::check;
 }