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:
@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user