Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

give better information to certin users who are denied entry #2252

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 13 additions & 23 deletions lib/WeBWorK/Authen.pm
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,7 @@ use WeBWorK::Localize;
use Caliper::Sensor;
use Caliper::Entity;

#####################
## WeBWorK-tr modification
## If GENERIC_ERROR_MESSAGE is constant, we can't translate it

#use vars qw($GENERIC_ERROR_MESSAGE);
our $GENERIC_ERROR_MESSAGE = ""; # define in new

## WeBWorK-tr end modification
#####################

#use constant GENERIC_ERROR_MESSAGE => "Invalid user ID or password.";
our $GENERIC_ERROR_MESSAGE = ""; # define in new

################################################################################
# Public API
Expand Down Expand Up @@ -451,18 +441,6 @@ sub check_user {

# FIXME "fix invalid status values" used to be here, but it needs to move to $db->getUser

unless ($ce->status_abbrev_has_behavior($User->status, "allow_course_access")) {
$self->{log_error} = "user not allowed course access";
$self->{error} = $GENERIC_ERROR_MESSAGE;
return 0;
}

unless ($authz->hasPermissions($user_id, "login")) {
$self->{log_error} = "user not permitted to login";
$self->{error} = $GENERIC_ERROR_MESSAGE;
return 0;
}

return 1;
}

Expand Down Expand Up @@ -529,6 +507,18 @@ sub verify_normal_user {
if ($auth_result > 0) {
$self->{session_key} = $self->create_session($user_id);
$self->{initial_login} = 1;
# deny certain roles (dropped students, proctor roles)
unless ($c->ce->status_abbrev_has_behavior($c->db->getUser($user_id)->status, "allow_course_access")) {
$self->{log_error} = "user not allowed course access";
$self->{error} = "This user is not allowed to log in to this course";
return 0;
}
# deny permission levels below "login" permission level
unless ($c->authz->hasPermissions($user_id, "login")) {
$self->{log_error} = "user not permitted to login";
$self->{error} = "This user is not allowed to log in to this course";
return 0;
}
return 1;
} elsif ($auth_result == 0) {
$self->{log_error} = "authentication failed";
Expand Down