mirror of
				https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
				synced 2025-10-31 02:37:56 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			942 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			942 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| //
 | |
| // Created by stephane bourque on 2022-01-31.
 | |
| //
 | |
| 
 | |
| #include "RESTAPI_totp_handler.h"
 | |
| #include "TotpCache.h"
 | |
| 
 | |
| namespace OpenWifi {
 | |
| 
 | |
| 	void RESTAPI_totp_handler::DoGet() {
 | |
| 
 | |
| 		auto Reset = GetBoolParameter("reset", false);
 | |
| 		std::string QRCode;
 | |
| 		if (TotpCache()->StartValidation(UserInfo_.userinfo, false, QRCode, Reset)) {
 | |
| 			return SendFileContent(QRCode, "image/svg+xml", "qrcode.svg");
 | |
| 		}
 | |
| 		return BadRequest(RESTAPI::Errors::InvalidCommand);
 | |
| 	}
 | |
| 
 | |
| 	void RESTAPI_totp_handler::DoPut() {
 | |
| 		auto Value = GetParameter("value", "");
 | |
| 		auto nextIndex = GetParameter("index", 0);
 | |
| 		bool moreCodes = false;
 | |
| 
 | |
| 		RESTAPI::Errors::msg Err;
 | |
| 		if (TotpCache()->ContinueValidation(UserInfo_.userinfo, false, Value, nextIndex, moreCodes,
 | |
| 											Err)) {
 | |
| 			Poco::JSON::Object Answer;
 | |
| 			Answer.set("nextIndex", nextIndex);
 | |
| 			Answer.set("moreCodes", moreCodes);
 | |
| 			return ReturnObject(Answer);
 | |
| 		}
 | |
| 		return BadRequest(Err);
 | |
| 	}
 | |
| 
 | |
| } // namespace OpenWifi
 | 
