core icon indicating copy to clipboard operation
core copied to clipboard

PersonaTool forcePersona() method doesn't work in Front End

Open oarrietadotcms opened this issue 8 years ago • 1 comments

Possible Solution

See hotfix.

Known Workarounds

Use Rules Engine.

Steps to Reproduce (for bugs)

  1. Create a Page + Simple Widget and paste this code:
Visitor: $visitor

#set( $results = $dotcontent.pull( "+contentType:persona +persona.keyTag:FirstTimeInvestor", 1, "modDate" ) )
#foreach( $persona in $results )
    <br>
    <br>
    Persona Found: $persona.keyTag
    $personatool.forcePersona( $persona.identifier )
#end
<br>
<br>
Visitor: $visitor
  1. Hit the page in front end.

Context

You will see the $personatool.forcePersona( $persona.identifier ) line in the Front End, that means that there is an error executing that line.

If you debug the code you will see this exception:

DotSecurityException: User:null does not have permissions to Contentlet:3ffaff2c-3b82-4bd6-8622-ec2637cc0ac6

That is because in this line we try to find the Persona content using the user logged. BUT we are sending algo the respectFrontendRoles flag as false. This will prevent the logic for anonymous roles to run.

Your Environment

  • dotCMS version used: 3.7.1 and latest master

oarrietadotcms avatar Feb 26 '18 21:02 oarrietadotcms

Passed QA. $personatool.forcePersona( $persona.identifier ) line is not showing anymore in the Front End

Tested on master branch Mac OS 10.10 / Postgres 9.6.6 / Chrome v64.0.3282.167 / Tomcat 8 / Java 8.6

shaydotcms avatar Mar 12 '18 21:03 shaydotcms