Skip to content

Commit 45a3e57

Browse files
committed
LTI import gen random password for new users.
Uses App::Genpass to generate 16 character random passwords for new users (if the user didn't specify one).
1 parent 1908e28 commit 45a3e57

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/WebworkBridge/Importer/CourseCreator.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use WeBWorK::Utils qw(runtime_use readFile cryptPassword);
1212

1313
use WebworkBridge::Importer::Error;
1414

15+
use App::Genpass;
1516
use Text::CSV;
1617

1718
# Constructor
@@ -97,6 +98,7 @@ sub createClassList
9798
# write students
9899
# profid may be a comma separated list of ids, to support multiple profs
99100
my @profid = split(/,/, $course{profid});
101+
my $genpass = App::Genpass->new(length=>16);
100102
foreach my $i (@students)
101103
{
102104
my $id = $i->{'loginid'};
@@ -115,7 +117,7 @@ sub createClassList
115117
print FILE "$id,"; # login id
116118
$i->{password} ?
117119
print FILE cryptPassword($i->{password})."," :
118-
print FILE ","; # password
120+
print FILE $genpass->generate,","; # password
119121
print FILE "$i->{'permission'}\n"; # permission
120122
}
121123

lib/WebworkBridge/Importer/CourseUpdater.pm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use warnings;
66

77
use Time::HiRes qw/gettimeofday/;
88
use Date::Format;
9+
use App::Genpass;
910

1011
use WeBWorK::CourseEnvironment;
1112
use WeBWorK::DB;
@@ -255,8 +256,9 @@ sub addUser
255256
$cryptedpassword = cryptPassword($new_user_info->{'password'});
256257
}
257258
else
258-
{
259-
$cryptedpassword = cryptPassword($new_user->student_id());
259+
{ # no password given, so default to random password
260+
my $genpass = App::Genpass->new(length=>16);
261+
$cryptedpassword = cryptPassword($genpass->generate);
260262
}
261263
my $password = $db->newPassword(user_id => $id);
262264
$password->password($cryptedpassword);

0 commit comments

Comments
 (0)