<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Protect API from calls outside of the private area]]></title><description><![CDATA[<p dir="auto">Hi there,</p>
<p dir="auto">how can I make sure that an API can only get called after the user has succesfully logged into the private area.</p>
<p dir="auto">I know how to protect the html pages, but I'm not yet sure what the best approach is for the API functions.</p>
<p dir="auto">Thanks in advance!</p>
]]></description><link>https://community.appdrag.com/topic/755/protect-api-from-calls-outside-of-the-private-area</link><generator>RSS for Node</generator><lastBuildDate>Tue, 10 Mar 2026 22:36:12 GMT</lastBuildDate><atom:link href="https://community.appdrag.com/topic/755.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 16 Mar 2021 20:51:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Protect API from calls outside of the private area on Wed, 17 Mar 2021 21:23:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.appdrag.com/uid/9">@Daniel-Mulroy</a> Hi Daniel, thanks! And sorry about the Dick Honing / ecOrganizer confusion. I created a second account to test the sharing settings before handing handing it over to third parties and somehow this account got stuck in Safari ...</p>
<p dir="auto">Btw: can I contact you backchannel / via email?</p>
]]></description><link>https://community.appdrag.com/post/3102</link><guid isPermaLink="true">https://community.appdrag.com/post/3102</guid><dc:creator><![CDATA[ec Organizer]]></dc:creator><pubDate>Wed, 17 Mar 2021 21:23:08 GMT</pubDate></item><item><title><![CDATA[Reply to Protect API from calls outside of the private area on Wed, 17 Mar 2021 10:31:56 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="https://community.appdrag.com/uid/190">@Dick-Honing</a> and <a class="plugin-mentions-user plugin-mentions-a" href="https://community.appdrag.com/uid/689">@ec-Organizer</a>,</p>
<p dir="auto">It looks like you already have a token system for authentication.</p>
<p dir="auto">A solution is to send that token along with every API call from the front-end.</p>
<p dir="auto">Then, in your API functions, you 'check' the token before running the actual function/returning any data.</p>
<p dir="auto">Something in Node.js might look like:</p>
<pre><code>if (tokenIsValid(event.POST.token) === false) {
    callback(null, {status: "NOT AUTH"}); // handle this error on the client side
    return // stop code execution
}

// Then continue with your normal function code here

</code></pre>
<p dir="auto">tokenIsValid, in this example, would check the token against the user database to ensure the token was valid.</p>
]]></description><link>https://community.appdrag.com/post/3097</link><guid isPermaLink="true">https://community.appdrag.com/post/3097</guid><dc:creator><![CDATA[Daniel Mulroy]]></dc:creator><pubDate>Wed, 17 Mar 2021 10:31:56 GMT</pubDate></item><item><title><![CDATA[Reply to Protect API from calls outside of the private area on Wed, 17 Mar 2021 09:34:31 GMT]]></title><description><![CDATA[<p dir="auto">An area/web pages the user has access to after loggin in.</p>
<p dir="auto">The private pages then all have the following additional bit of Javascript to protect these pages from direct access without having logged in first:</p>
<pre><code>&lt;script&gt;
    //Wait for jquery to load before executing code
    addEventListener('JqueryLoaded', function(e) {
        var readEmail = sessionStorage.getItem('email');
        var readToken = sessionStorage.getItem('token');
        if (readEmail == "" || readEmail == null || readToken == "" || readToken == null) {
            window.location.href = 'login.html';
        }
    }, false);
&lt;/script&gt;
</code></pre>
<p dir="auto">Now I also want to protect the API functions from being accessed by anybody what has not successfully logged into the private area ...</p>
]]></description><link>https://community.appdrag.com/post/3096</link><guid isPermaLink="true">https://community.appdrag.com/post/3096</guid><dc:creator><![CDATA[ec Organizer]]></dc:creator><pubDate>Wed, 17 Mar 2021 09:34:31 GMT</pubDate></item><item><title><![CDATA[Reply to Protect API from calls outside of the private area on Wed, 17 Mar 2021 07:16:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">What do you call the private area?</p>
]]></description><link>https://community.appdrag.com/post/3090</link><guid isPermaLink="true">https://community.appdrag.com/post/3090</guid><dc:creator><![CDATA[Wassim]]></dc:creator><pubDate>Wed, 17 Mar 2021 07:16:59 GMT</pubDate></item></channel></rss>