<commit_before>package com.ilearnrw.common.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;

import com.ilearnrw.common.security.users.model.User;
import com.ilearnrw.common.security.users.services.TeacherStudentService;
import com.ilearnrw.common.security.users.services.UserService;

public class ProfilePermissionChecker implements PermissionChecker {

	@Autowired
	private TeacherStudentService teacherStudentService;

	@Autowired
	private UserService userService;

	@Override
	public boolean isAllowed(Authentication authentication,
			Object targetDomainObject) {

		boolean isAllowed = false;
		if (targetDomainObject instanceof String) {
			String userId = (String) targetDomainObject;
			User user = userService.getUser(Integer.parseInt(userId));
			String loggedInUser = (String) authentication.getPrincipal();
			isAllowed = (loggedInUser.compareTo(user.getUsername()) == 0 || teacherStudentService
					.isUserStudentOfTeacher(user.getUsername(), loggedInUser));
		}

		return isAllowed;
	}

}
<commit_msg>userId was changed from String to int. The permission checker had to be updated as well<commit_after>package com.ilearnrw.common.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;

import com.ilearnrw.common.security.users.model.User;
import com.ilearnrw.common.security.users.services.TeacherStudentService;
import com.ilearnrw.common.security.users.services.UserService;

public class ProfilePermissionChecker implements PermissionChecker {

	@Autowired
	private TeacherStudentService teacherStudentService;

	@Autowired
	private UserService userService;

	@Override
	public boolean isAllowed(Authentication authentication,
			Object targetDomainObject) {

		boolean isAllowed = false;
		if (targetDomainObject instanceof Integer) {
			int userId = (Integer) targetDomainObject;
			User user = userService.getUser(userId);
			String loggedInUser = (String) authentication.getPrincipal();
			isAllowed = (loggedInUser.compareTo(user.getUsername()) == 0 || teacherStudentService
					.isUserStudentOfTeacher(user.getUsername(), loggedInUser));
		}

		return isAllowed;
	}

}

{'fraction_non_alphanumeric': 0.0860310421286031, 'fraction_numerical': 0.0008869179600886918, 'mean_word_length': 6.05, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7061242', 'n_tokens_mistral': 646, 'n_tokens_neox': 617, 'n_words': 131}