1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-21 00:55:17 +00:00

Can check user tokens

This commit is contained in:
2019-11-23 13:47:06 +01:00
parent 1ddf156cc4
commit c304c2f88e
4 changed files with 70 additions and 3 deletions

View File

@ -80,6 +80,33 @@ export class AccountHelper {
return row == null ? null : this.DBToUserTokens(row);
}
/**
* Find a user using its tokens
*
* @param client Information about the client
* @param token1 First token
* @param token2 Second token
* @returns The ID of the target user / -1 if none found
*/
public static async GetUserIdFromTokens(client : APIClient,
token1: string, token2: string) : Promise<number> {
const row = await DatabaseHelper.QueryRow({
table: USERS_TOKENS_TABLE,
fields: ["user_id"],
where: {
service_id: client.id,
token1: token1,
token2: token2
}
});
if(!row)
return -1;
return Number(row.user_id);
}
/**
* Crypt a password
*