use of fi.otavanopisto.pyramus.dao.base.PersonDAO in project pyramus by otavanopisto.
the class EditStudentViewController method checkAccess.
@Override
protected boolean checkAccess(RequestContext requestContext) {
UserDAO userDAO = DAOFactory.getInstance().getUserDAO();
PersonDAO personDAO = DAOFactory.getInstance().getPersonDAO();
Long loggedUserId = requestContext.getLoggedUserId();
User user = userDAO.findById(loggedUserId);
if (!Permissions.instance().hasEnvironmentPermission(user, PyramusViewPermissions.EDIT_STUDENT)) {
return false;
} else {
if (UserUtils.canAccessAllOrganizations(user)) {
return true;
} else {
Long personId = requestContext.getLong("person");
Person person = personDAO.findById(personId);
for (Student student : person.getStudents()) {
if (UserUtils.isMemberOf(user, student.getOrganization())) {
// Having one common organization is enough - though the view may not allow editing all
return true;
}
}
return false;
}
}
}
use of fi.otavanopisto.pyramus.dao.base.PersonDAO in project pyramus by otavanopisto.
the class AdminPasswordSetupWizardViewController method save.
@Override
public void save(PageRequestContext requestContext) throws SetupWizardException {
String username = requestContext.getString("username");
String password = requestContext.getString("password1");
String firstName = requestContext.getString("firstName");
String lastName = requestContext.getString("lastName");
String passwordMD5 = DigestUtils.md5Hex(password);
StaffMemberDAO userDAO = DAOFactory.getInstance().getStaffMemberDAO();
InternalAuthDAO internalAuthDAO = DAOFactory.getInstance().getInternalAuthDAO();
PersonDAO personDAO = DAOFactory.getInstance().getPersonDAO();
UserIdentificationDAO userIdentificationDAO = DAOFactory.getInstance().getUserIdentificationDAO();
DefaultsDAO defaultsDAO = DAOFactory.getInstance().getDefaultsDAO();
Defaults defaults = defaultsDAO.getDefaults();
InternalAuth internalAuth = internalAuthDAO.create(username, passwordMD5);
Person person = personDAO.create(null, null, null, null, Boolean.FALSE);
userIdentificationDAO.create(person, "internal", String.valueOf(internalAuth.getId()));
User user = userDAO.create(defaults.getOrganization(), firstName, lastName, Role.ADMINISTRATOR, person, false);
personDAO.updateDefaultUser(person, user);
}
Aggregations