Doubt with AuthTokenUtil methods on Liferay 7

Daniel G, modified 5 Years ago. Regular Member Posts: 141 Join Date: 3/14/17 Recent Posts
Hi all,
I have a doubt about a method of AuthTokenUtil. I am upgrading a Liferay 6 to Liferay 7 and I am not sure what to do with one method.
In Liferay 6 I have this piece of code :
[table]
[tr]
[td]try {[/td]
[/tr]
[tr]
[td][/td]
[td]    HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(PortalUtil.getHttpServletRequest(resourceRequest)){[/td]
[/tr]
[tr]
[td][/td]
[td]        @Override[/td]
[/tr]
[tr]
[td][/td]
[td]        public String getParameter(String name) {[/td]
[/tr]
[tr]
[td][/td]
[td]            if (name.equals("p_auth")) {[/td]
[/tr]
[tr]
[td][/td]
[td]                return PortalUtil.getOriginalServletRequest((HttpServletRequest) super.getRequest()).getParameter(name);[/td]
[/tr]
[tr]
[td][/td]
[td]            }[/td]
[/tr]
[tr]
[td][/td]
[td]
[/td]
[/tr]
[tr]
[td][/td]
[td]            return super.getParameter(name);[/td]
[/tr]
[tr]
[td][/td]
[td]        }[/td]
[/tr]
[tr]
[td][/td]
[td]    };[/td]
[/tr]
[tr]
[td][/td]
[td]    AuthTokenUtil.check(wrapper);[/td]
[/tr]
[tr]
[td][/td]
[td]} catch (Exception e) {[/td]
[/tr]
[tr]
[td][/td]
[td]    throw new PortletException("Invalid CSRF token!", e);[/td]
[/tr]
[tr]
[td][/td]
[td]}

However, the method "check" is no longer available.
Does anyone know how is the right way to do it now? I was looking at the "checkCSRFToken" but I'm not sure that this method will be the same than the old one.
Any help would be very appreciated.
Kind regards.

thumbnail
Mohammed Yasin, modified 5 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts
Hi ,You can use AuthTokenUtil.checkCSRFToken(request, origin); may be you can refer below how it is used 
https://github.com/liferay/liferay-portal/blob/7.2.x/portal-impl/src/com/liferay/portal/action/UpdateEmailAddressAction.java#L88