9 use Text::Tradition::UserStore;
13 my ($dsn, $command) = ('dbi:SQLite:dbname=db/traditions.db', 'add', undef);
14 my ($username, $password);
17 'c|command:s' => \$command,
19 'u|username=s' => \$username,
20 'p|password:s' => \$password,
23 if(!$command || !($command ~~ [qw/add modify delete/])) {
24 print "No command supplied, chickening out ... \n\n";
29 print "No username supplied, confused ... \n\n";
33 my $userstore = Text::Tradition::UserStore->new( dsn => $dsn);
37 if(!$password || !$userstore->validate_password($password)) {
38 print "Can't add a new user without a valid password\n\n";
41 my $user = $userstore->add_user({ username => $username,
42 password => $password });
44 print "Failed to add user! (you should see errors above this..)\n";
51 if(!$password || !$userstore->validate_password($password)) {
52 print "Can't modify a user without a valid password\n\n";
55 my $user = $userstore->modify_user({ username => $username,
56 password => $password });
58 print "Failed to modify user! (you should see errors above this..)\n";
64 my $user = $userstore->delete_user({ username => $username});
66 print "Failed to modify user! (you should see errors above this..)\n";
74 print "User Admin tool, to add/remove/modify users\n";
75 print "===========================================\n";
76 print "Usage: $0 -c add -u jimbob -p hispassword\n";
77 print "Usage: $0 -c modify -u jimbob -p hisnewpassword\n";
78 print "Usage: $0 -c delete -u jimbob\n";
83 admin_users.pl - add / modify / delete users
87 admin_user.pl -c add -u jimbob -p "jimspassword"
89 admin_user.pl -c modify -u jimbob -p "jimsnewpassword"
91 admin_user.pl -c delete -u jimbob
99 The action to take, can be one of: add, modify, delete.
101 =item -u | --username
103 The username of the new user or user to change.
105 =item -p | --password
107 The new password or password to change.