added permission checks to templates