mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-04 11:34:04 +00:00 
			
		
		
		
	Can get the ID of a user from its email address
This commit is contained in:
		@@ -209,6 +209,21 @@ export class RequestHandler {
 | 
				
			|||||||
		return userID;
 | 
							return userID;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Find user ID based on its email address, included in a POST request
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param name The name of the POST field containing the email address of the user
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public async postUserIdFromEmail(name: string) : Promise<number> {
 | 
				
			||||||
 | 
							const email = this.postEmail(name);
 | 
				
			||||||
 | 
							const userID = await AccountHelper.FindIDFromEmail(email);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(userID < 1)
 | 
				
			||||||
 | 
								this.error(404, "Email not found!");
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							return userID;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Get a POST group ID
 | 
						 * Get a POST group ID
 | 
				
			||||||
	 * 
 | 
						 * 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -175,6 +175,24 @@ export class AccountHelper {
 | 
				
			|||||||
		}) > 0;
 | 
							}) > 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Find user ID from its email address
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param email Email address
 | 
				
			||||||
 | 
						 * @returns The ID of the matching user / -1 if none found
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public static async FindIDFromEmail(email: string) : Promise<number> {
 | 
				
			||||||
 | 
							const result = await DatabaseHelper.QueryRow({
 | 
				
			||||||
 | 
								table: USER_TABLE,
 | 
				
			||||||
 | 
								where: {
 | 
				
			||||||
 | 
									mail: email,
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								fields: ["ID"]
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return result == null ? -1 : result.ID;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Check out whether a virtual directory is available or not
 | 
						 * Check out whether a virtual directory is available or not
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user