Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub login_user {
- my ($self,$authenKey,$courseName,$userID) = @_;
- my $soapEnv = new WebworkSOAP($authenKey,$courseName);
- my $newKey;
- my $timestamp = time;
- my @chars = @{ $soapEnv->{ce}->{sessionKeyChars} };
- my $length = $soapEnv->{ce}->{sessionKeyLength};
- srand;
- $newKey = join ("", @chars[map rand(@chars), 1 .. $length]);
- my $Key = $soapEnv->{db}->newKey(user_id=>$userID, key=>$newKey, timestamp=>$timestamp);
- eval { $soapEnv->{db}->deleteKey($userID) };
- eval { $soapEnv->{db}->addKey($Key) };
- $@ and soap_fault(SOAPERROR_USER_NOT_FOUND,"User not found.");
- my $log_msg = "LOGIN OK: user_id=$userID login_type=SOAP";
- writeCourseLog($soapEnv->{ce},"login_log",$log_msg);
- return SOAP::Data->type( 'string', $newKey );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement