mirror of
				https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
				synced 2025-10-31 18:57:51 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			36 lines
		
	
	
		
			904 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			904 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| //
 | |
| // Created by stephane bourque on 2021-11-16.
 | |
| //
 | |
| 
 | |
| #include "RESTAPI_subpreferences.h"
 | |
| #include "StorageService.h"
 | |
| 
 | |
| namespace OpenWifi {
 | |
| 
 | |
|     void RESTAPI_subpreferences::DoGet() {
 | |
|         SecurityObjects::Preferences    P;
 | |
|         Poco::JSON::Object  Answer;
 | |
|         StorageService()->SubPreferencesDB().GetPreferences(UserInfo_.userinfo.Id, P);
 | |
|         P.to_json(Answer);
 | |
|         ReturnObject(Answer);
 | |
|     }
 | |
| 
 | |
|     void RESTAPI_subpreferences::DoPut() {
 | |
| 
 | |
|         SecurityObjects::Preferences    P;
 | |
| 
 | |
|         auto RawObject = ParseStream();
 | |
|         if(!P.from_json(RawObject)) {
 | |
|             return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
 | |
|         }
 | |
| 
 | |
|         P.id = UserInfo_.userinfo.Id;
 | |
|         P.modified = std::time(nullptr);
 | |
|         StorageService()->SubPreferencesDB().SetPreferences(P);
 | |
| 
 | |
|         Poco::JSON::Object  Answer;
 | |
|         P.to_json(Answer);
 | |
|         ReturnObject(Answer);
 | |
|     }
 | |
| 
 | |
| } | 
