Enable full size images preview for users with extended search rights

pull/154/head
luccioman 7 years ago
parent d42c1773c8
commit f52217c939

@ -47,6 +47,7 @@ import net.yacy.cora.util.ConcurrentLog;
import net.yacy.crawler.retrieval.StreamResponse; import net.yacy.crawler.retrieval.StreamResponse;
import net.yacy.data.InvalidURLLicenceException; import net.yacy.data.InvalidURLLicenceException;
import net.yacy.data.URLLicense; import net.yacy.data.URLLicense;
import net.yacy.data.UserDB;
import net.yacy.http.servlets.TemplateMissingParameterException; import net.yacy.http.servlets.TemplateMissingParameterException;
import net.yacy.peers.graphics.EncodedImage; import net.yacy.peers.graphics.EncodedImage;
import net.yacy.repository.Blacklist.BlacklistType; import net.yacy.repository.Blacklist.BlacklistType;
@ -146,9 +147,20 @@ public class ImageViewer {
* @param sb switchboard instance. * @param sb switchboard instance.
* @return true when full image view is allowed for this request * @return true when full image view is allowed for this request
*/ */
public static boolean hasFullViewingRights(final RequestHeader header, Switchboard sb) { public static boolean hasFullViewingRights(final RequestHeader header, final Switchboard sb) {
return header != null && (Domains.isLocalhost(header.getRemoteAddr()) boolean extendedSearchRights = false;
|| (sb != null && sb.verifyAuthentication(header))); if(sb != null && header != null) {
final boolean adminAuthenticated = sb.verifyAuthentication(header);
if (adminAuthenticated) {
extendedSearchRights = true;
} else {
final UserDB.Entry user = sb.userDB != null ? sb.userDB.getUser(header) : null;
if (user != null) {
extendedSearchRights = user.hasRight(UserDB.AccessRight.EXTENDED_SEARCH_RIGHT);
}
}
}
return header != null && (extendedSearchRights || Domains.isLocalhost(header.getRemoteAddr()));
} }
/** /**

Loading…
Cancel
Save