mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-04 03:24:04 +00:00 
			
		
		
		
	Can check through the API whether an email address exists or not
This commit is contained in:
		@@ -64,4 +64,18 @@ export class AccountController {
 | 
				
			|||||||
			userID: handler.getUserId()
 | 
								userID: handler.getUserId()
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Check out whether an email is associated to an account
 | 
				
			||||||
 | 
						 * or not
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param h Request handler
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public static async ExistsMail(h: RequestHandler) {
 | 
				
			||||||
 | 
							const email = h.postEmail("email");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							h.send({
 | 
				
			||||||
 | 
								exists: await AccountHelper.ExistsEmail(email)
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -43,6 +43,8 @@ export const Routes : Route[] = [
 | 
				
			|||||||
	{path: "/account/id", cb: (h) => AccountController.CurrentUserID(h)},
 | 
						{path: "/account/id", cb: (h) => AccountController.CurrentUserID(h)},
 | 
				
			||||||
	{path: "/user/getCurrentUserID", cb: (h) => AccountController.CurrentUserID(h)}, // Legacy
 | 
						{path: "/user/getCurrentUserID", cb: (h) => AccountController.CurrentUserID(h)}, // Legacy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{path: "/account/exists_email", cb: (h) => AccountController.ExistsMail(h), needLogin: false},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// User controller
 | 
						// User controller
 | 
				
			||||||
	{path: "/user/getInfo", cb: (h) => UserController.GetSingle(h), needLogin: false},
 | 
						{path: "/user/getInfo", cb: (h) => UserController.GetSingle(h), needLogin: false},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -161,6 +161,20 @@ export class AccountHelper {
 | 
				
			|||||||
		};
 | 
							};
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Check out whether an email address exists or not
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param email Email address to check
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public static async ExistsEmail(email: string) : Promise<boolean> {
 | 
				
			||||||
 | 
							return await DatabaseHelper.Count({
 | 
				
			||||||
 | 
								table: USER_TABLE,
 | 
				
			||||||
 | 
								where: {
 | 
				
			||||||
 | 
									mail: email
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}) > 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * 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