<?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[Authorization in all rooms]]></title><description><![CDATA[<p>I created an auth room where I load the player data from the database</p>
<pre><code>    async onAuth(options) {
        //FIXME check fb auth key
        const data = await gameDao.fetchPlayer(options.uid);
        if (data.rows.length &gt; 0) {
            return data.rows[0];
        }
        return false;
    }

    onJoin(client, options, auth) {
        var player = new Player(client.id, auth.name);
        client.player = player;
    }
</code></pre>
<p>how to check in another room player data?</p>
<pre><code>    // Code from play room
    async onAuth(options) {
        // this need check player data
        return false;
    }
</code></pre>
<p>for example, that players can not enter the location for high levels or the availability of game modes for premium players</p>
]]></description><link>http://discuss.colyseus.io/topic/60/authorization-in-all-rooms</link><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Mar 2026 20:45:58 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/60.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 06 Apr 2018 14:24:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Authorization in all rooms on Fri, 06 Apr 2018 14:28:59 GMT]]></title><description><![CDATA[<p>I created an auth room where I load the player data from the database</p>
<pre><code>    async onAuth(options) {
        //FIXME check fb auth key
        const data = await gameDao.fetchPlayer(options.uid);
        if (data.rows.length &gt; 0) {
            return data.rows[0];
        }
        return false;
    }

    onJoin(client, options, auth) {
        var player = new Player(client.id, auth.name);
        client.player = player;
    }
</code></pre>
<p>how to check in another room player data?</p>
<pre><code>    // Code from play room
    async onAuth(options) {
        // this need check player data
        return false;
    }
</code></pre>
<p>for example, that players can not enter the location for high levels or the availability of game modes for premium players</p>
]]></description><link>http://discuss.colyseus.io/post/187</link><guid isPermaLink="true">http://discuss.colyseus.io/post/187</guid><dc:creator><![CDATA[colyseus_]]></dc:creator><pubDate>Fri, 06 Apr 2018 14:28:59 GMT</pubDate></item><item><title><![CDATA[Reply to Authorization in all rooms on Invalid Date]]></title><description><![CDATA[<p>Hi @colyseus,</p>
<p>You'd need to get the player's information during <code>onAuth</code> in every room he connects to. If you created a <code>AuthRoom</code> with the authentication method, you may want create the <code>PlayRoom</code> extending <code>AuthRoom</code> to have the exact same method.</p>
<p>Something like this (I've wrote this quickly and haven't tested)</p>
<pre><code>export class PlayRoom extends AuthRoom {
  levelRequired = 5;

  async onAuth (options) {
    const data = await super.onAuth();
    if (data.level &gt;= this.levelRequired) {
      return data;
    } else {
      return false;
    }
  }
}
</code></pre>
<p>Not sure if that's your question. Let me know if that helps.</p>
<p>Cheers!</p>
]]></description><link>http://discuss.colyseus.io/post/188</link><guid isPermaLink="true">http://discuss.colyseus.io/post/188</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Authorization in all rooms on Fri, 06 Apr 2018 17:29:24 GMT]]></title><description><![CDATA[<p>:astonished:  this is suitable, thank you very much!</p>
]]></description><link>http://discuss.colyseus.io/post/189</link><guid isPermaLink="true">http://discuss.colyseus.io/post/189</guid><dc:creator><![CDATA[colyseus_]]></dc:creator><pubDate>Fri, 06 Apr 2018 17:29:24 GMT</pubDate></item></channel></rss>