mirror of
				https://github.com/pierre42100/ComunicAPI
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Can get the security questions of a user
This commit is contained in:
		@@ -97,6 +97,36 @@ class accountController {
 | 
				
			|||||||
		);
 | 
							);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Get the security questions of a user using its email address
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @url POST /account/get_security_questions
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public function getSecurityQuestions(){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Get account ID
 | 
				
			||||||
 | 
							$userID = $this->getUserIDFromPostEmail("email");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Check if user has defined security questions
 | 
				
			||||||
 | 
							if(!components()->settings->has_security_questions($userID))
 | 
				
			||||||
 | 
								Rest_fatal_error(401, "Specified user has not set up security questions!");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Get the security settings of the user
 | 
				
			||||||
 | 
							$settings = components()->settings->get_security($userID);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Check for errors
 | 
				
			||||||
 | 
							if(!$settings->isValid())
 | 
				
			||||||
 | 
								Rest_fatal_error(500, "An error occurred while retrieving security settings of the user!");
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							//Return the questions of the user
 | 
				
			||||||
 | 
							return array(
 | 
				
			||||||
 | 
								"questions" => array(
 | 
				
			||||||
 | 
									$settings->get_security_question_1(),
 | 
				
			||||||
 | 
									$settings->get_security_question_2()
 | 
				
			||||||
 | 
								)
 | 
				
			||||||
 | 
							);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Create an account
 | 
						 * Create an account
 | 
				
			||||||
	 * 
 | 
						 * 
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user