Skip to content

Commit 5c20ed2

Browse files
committed
Fix an issue with the navigation_allowed permission.
Do not let a user view another set other than the one in the session if a user does not have the `navigation_allowed` permission. Generally, the only way this will happen is if the user modifies the URL in the browser to try to change to a different set. Currently that works, and it shouldn't.
1 parent 1f6c51f commit 5c20ed2

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

lib/WeBWorK/Authz.pm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,18 @@ sub checkSet {
434434
return $c->maketext("Requested set '[_1]' is not available yet.", $setName);
435435
}
436436

437+
if (!$self->hasPermissions($userName, 'navigation_allowed') && $c->authen->session->{set_id} ne $setName) {
438+
$c->{viewSetCheck} = 'restricted';
439+
if ($ce->{LTI}) {
440+
# Note that this content is HTML escaped in the template, and so this may not contain the link to
441+
# $ce->{LTI}{ $ce->{LTIVersion} }{LMS_url} as is done with similar such messages for this.
442+
return $c->maketext('You must access this assignment from your Course Management System ([_1]).',
443+
$ce->{LTI}{ $ce->{LTIVersion} }{LMS_name});
444+
} else {
445+
return $c->maketext('You do not have permission to access this set.');
446+
}
447+
}
448+
437449
# Check to see if conditional release conditions have been met.
438450
my $conditional_msg = restricted_set_message($c, $set, 'conditional');
439451
if ($conditional_msg) {

0 commit comments

Comments
 (0)