Close if already identified
This commit is contained in:
parent
a9eac479bb
commit
df696d362a
@ -59,7 +59,6 @@ import { check } from "./instanceOf";
|
|||||||
|
|
||||||
// TODO: user sharding
|
// TODO: user sharding
|
||||||
// TODO: check privileged intents, if defined in the config
|
// TODO: check privileged intents, if defined in the config
|
||||||
// TODO: check if already identified
|
|
||||||
|
|
||||||
const getUserFromToken = async (token: string): Promise<string | null> => {
|
const getUserFromToken = async (token: string): Promise<string | null> => {
|
||||||
try {
|
try {
|
||||||
@ -73,6 +72,11 @@ const getUserFromToken = async (token: string): Promise<string | null> => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function onIdentify(this: WebSocket, data: Payload) {
|
export async function onIdentify(this: WebSocket, data: Payload) {
|
||||||
|
if (this.user_id) {
|
||||||
|
// we've already identified
|
||||||
|
return this.close(CLOSECODES.Already_authenticated);
|
||||||
|
}
|
||||||
|
|
||||||
clearTimeout(this.readyTimeout);
|
clearTimeout(this.readyTimeout);
|
||||||
|
|
||||||
// Check payload matches schema
|
// Check payload matches schema
|
||||||
@ -106,7 +110,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
this.shard_id < 0 ||
|
this.shard_id < 0 ||
|
||||||
this.shard_count <= 0
|
this.shard_count <= 0
|
||||||
) {
|
) {
|
||||||
// TODO: why do we even care about this?
|
// TODO: why do we even care about this right now?
|
||||||
console.log(
|
console.log(
|
||||||
`[Gateway] Invalid sharding from ${user_id}: ${identify.shard}`,
|
`[Gateway] Invalid sharding from ${user_id}: ${identify.shard}`,
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user