summaryrefslogtreecommitdiff
path: root/FS/bin/freeside-adduser
blob: 6b4becb5fde045a2ff4229e2bfa0ee75c9bf7141 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/perl -w

use strict;
use vars qw($opt_s $opt_g $opt_n);
use Fcntl qw(:flock);
use Getopt::Std;

my $FREESIDE_CONF = "%%%FREESIDE_CONF%%%";

getopts("g:");
my $user = shift or die &usage;
my $password = shift;

use FS::UID qw(adminsuidsetup);
use FS::CurrentUser;
use FS::access_user;
use FS::access_usergroup;

$FS::CurrentUser::upgrade_hack = 1;
#adminsuidsetup $rootuser;
adminsuidsetup $user;

my $access_user = new FS::access_user {
  'username'  => $user,
  'first'     => 'Firstname', # $opt_f || 
  'last'      => 'Lastname',  # $opt_l || 
};
$access_user->change_password_fields($password) if length($password);
my $au_error = $access_user->insert;
die $au_error if $au_error;

if ( $opt_g ) {

  my $access_usergroup = new FS::access_usergroup {
    'usernum'  => $access_user->usernum,
    'groupnum' => $opt_g,
  };
  my $aug_error = $access_usergroup->insert;
  die $aug_error if $aug_error;

}

###

sub usage {
  die "Usage:\n\n  freeside-adduser [ -g groupnum ] username [ password ]"
}

=head1 NAME

freeside-adduser - Command line interface to add (freeside) users.

=head1 SYNOPSIS

  freeside-adduser [ -g groupnum ] username [ password ]

=head1 DESCRIPTION

Adds a user to the Freeside billing system.  This is for adding users (internal
sales/tech folks) to the web interface, not for adding customer accounts.

This functionality is now available in the web interface as well, under
B<Configuration | Employees | View/Edit employees>.

  -g: initial groupnum

=head1 SEE ALSO

Base Freeside documentation

=cut