Use @security.Authenticate to account permission validation

In my project ,I often refer to permission validation of account.but it’s too rudundant,so i want to Separate out the same permission validation parts ,integrate it into a class and use @security.Authenticate to validation.but it has two error:
package models.accounts can’ exsit.
can’t find symbol
symbol:method session(java.lang.String),
location:class inceptors.common.Permission
[error] Account account = Account.finder.byId(userIdd);

this is my code:

package inceptors.common;


import controllers.common.ErrDefinition;
import play.Logger;
import play.cache.CacheApi;
import play.libs.Json;
import play.mvc.;
import play.mvc.Http.
import play.i18n.Messages;
import controllers.common.CodeException;
import models.accounts.Account;
import javax.inject.Inject;

public class Permission extends Security.Authenticator {
public void permissionValiation(){
String userIdd = session(“usreId”);
Account account = Account.finder.byId(userIdd);
if (account == null) {
throw new CodeException(ErrDefinition.E_ACCOUNT_INCORRECT_PARAM);

	if (account.roleType != 0 && account.roleType !=1) {
		throw new CodeException(ErrDefinition.E_ACCOUNT_UNAUTHENTICATED);


who can help me ,thanks

Can you post the exact exception? Please put it in code </> snippets. Also please attach your application.conf or whatever config file you are using.

1 Like