Hi Rajith,

We can use modules for reusable js codes. Please refer modules sample in
the Features app[1]. So in your case, I think we can add the *onGet*
function to a module since it is reusable and include that module in all
the js files where you want to perform this check.

[1]
https://github.com/wso2/carbon-uuf/blob/master/samples/apps/org.wso2.carbon.uuf.sample.features-app.app/src/main/pages/include-module.hbs

Thanks,
Shan.


On Sun, Feb 5, 2017 at 12:14 PM, Rajith Roshan <[email protected]> wrote:

> Hi Devs,
>
> I have written a logic to check for a cookie[1] when /publisher context is
> requested. It will hit the OnGet method of index.js of publisher app.
> But I need to perform this logic for all requests like /publisher/apis,
> /publisher/create and etc. I can not copy the same logic to all js files.
> Is there a common place in UUF where we can handle this kind of scenario
> using back end Javascript.
>
> [1] - function onGet(env) {
>
>     if(!env.request.getCookieValue("token1")) {
>         sendRedirect("commons/login");
>     }
>     sendRedirect("apis");
> }
>
>
> Thanks!
> Rajith
>
>
> Rajith Roshan
> Software Engineer, WSO2 Inc.
> Mobile: +94-72-642-8350 <%2B94-71-554-8430>
>



-- 
Shan Mahanama

Software Engineer, WSO2 Inc. http://wso2.com
<http://l.facebook.com/l.php?u=http%3A%2F%2Fwso2.com&h=gAQEswASa>
Email: [email protected]
Mobile: +94 71 2000 498
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to