diff options
author | Ivan Kohler <ivan@freeside.biz> | 2013-11-09 12:03:47 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2013-11-09 12:03:47 -0800 |
commit | 9545a93c2cb4ee76c4226e0eacf9a6fb9c169adf (patch) | |
tree | 81fb378b0551ae41cf55fc3695c4fb53a678745b /FS/FS/svc_phone.pm | |
parent | 9c533839580e7914f6e64170ffe7aa76fc945275 (diff) |
add sip_passwordmin/max, RT#25239
Diffstat (limited to 'FS/FS/svc_phone.pm')
-rw-r--r-- | FS/FS/svc_phone.pm | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm index 77b0137..72c609c 100644 --- a/FS/FS/svc_phone.pm +++ b/FS/FS/svc_phone.pm @@ -2,9 +2,12 @@ package FS::svc_phone; use strict; use base qw( FS::svc_Domain_Mixin FS::location_Mixin FS::svc_Common ); -use vars qw( $DEBUG $me @pw_set $conf $phone_name_max ); +use vars qw( $DEBUG $me @pw_set $conf $phone_name_max + $passwordmin $passwordmax + ); use Data::Dumper; use Scalar::Util qw( blessed ); +use List::Util qw( min ); use FS::Conf; use FS::Record qw( qsearch qsearchs dbh ); use FS::PagedSearch qw( psearch ); @@ -26,6 +29,8 @@ $DEBUG = 0; FS::UID->install_callback( sub { $conf = new FS::Conf; $phone_name_max = $conf->config('svc_phone-phone_name-max_length'); + $passwordmin = $conf->config('sip_passwordmin') || 0; + $passwordmax = $conf->config('sip_passwordmax') || 80; } ); @@ -534,10 +539,17 @@ sub check { } } - unless ( length($self->sip_password) ) { # option for this? + if ( length($self->sip_password) ) { + + return "SIP password must be longer than $passwordmin characters" + if length($self->sip_password) < $passwordmin; + return "SIP password must be shorter than $passwordmax characters" + if length($self->sip_password) > $passwordmax; + + } else { # option for this? $self->sip_password( - join('', map $pw_set[ int(rand $#pw_set) ], (0..16) ) + join('', map $pw_set[ int(rand $#pw_set) ], (1..min($passwordmax,16)) ) ); } |