mirror of
				https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
				synced 2025-10-31 18:57:51 +00:00 
			
		
		
		
	Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
		| @@ -37,15 +37,12 @@ namespace OpenWifi { | ||||
|  | ||||
| 		while (Running_) { | ||||
| 			Poco::Thread::trySleep(2000); | ||||
|             DBGLINE | ||||
| 			if (!Running_) | ||||
| 				break; | ||||
| 			std::vector<SecurityObjects::ActionLink> Links; | ||||
| 			{ | ||||
| 				std::lock_guard G(Mutex_); | ||||
|                 DBGLINE | ||||
| 				StorageService()->ActionLinksDB().GetActions(Links); | ||||
|                 DBGLINE | ||||
| 			} | ||||
|  | ||||
| 			if (Links.empty()) | ||||
| @@ -56,120 +53,88 @@ namespace OpenWifi { | ||||
| 					break; | ||||
|  | ||||
| 				SecurityObjects::UserInfo UInfo; | ||||
|                 DBGLINE | ||||
| 				if ((i.action == OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD || | ||||
| 					 i.action == OpenWifi::SecurityObjects::LinkActions::VERIFY_EMAIL) && | ||||
| 					!StorageService()->UserDB().GetUserById(i.userId, UInfo)) { | ||||
|                     DBGLINE | ||||
| 					StorageService()->ActionLinksDB().CancelAction(i.id); | ||||
|                     DBGLINE | ||||
| 					continue; | ||||
| 				} else if ((i.action == | ||||
| 								OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD || | ||||
| 							i.action == OpenWifi::SecurityObjects::LinkActions::SUB_VERIFY_EMAIL || | ||||
| 							i.action == OpenWifi::SecurityObjects::LinkActions::SUB_SIGNUP) && | ||||
| 						   !StorageService()->SubDB().GetUserById(i.userId, UInfo)) { | ||||
|                     DBGLINE | ||||
| 					StorageService()->ActionLinksDB().CancelAction(i.id); | ||||
|                     DBGLINE | ||||
| 					continue; | ||||
| 				} else if ((i.action == OpenWifi::SecurityObjects::LinkActions::EMAIL_INVITATION) && | ||||
| 						   (OpenWifi::Now() - i.created) > (24 * 60 * 60)) { | ||||
|                     DBGLINE | ||||
| 					StorageService()->ActionLinksDB().CancelAction(i.id); | ||||
|                     DBGLINE | ||||
| 					continue; | ||||
| 				} | ||||
|  | ||||
|                 DBGLINE | ||||
| 				switch (i.action) { | ||||
| 				case OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD: { | ||||
|                     DBGLINE | ||||
| 					if (AuthService()->SendEmailToUser(i.id, UInfo.email, | ||||
| 													   MessagingTemplates::FORGOT_PASSWORD)) { | ||||
| 						poco_information( | ||||
| 							Logger(), fmt::format("Send password reset link to {}", UInfo.email)); | ||||
| 					} | ||||
|                     DBGLINE | ||||
| 					StorageService()->ActionLinksDB().SentAction(i.id); | ||||
|                     DBGLINE | ||||
| 				} break; | ||||
|  | ||||
| 				case OpenWifi::SecurityObjects::LinkActions::VERIFY_EMAIL: { | ||||
|                     DBGLINE | ||||
| 					if (AuthService()->SendEmailToUser(i.id, UInfo.email, | ||||
| 													   MessagingTemplates::EMAIL_VERIFICATION)) { | ||||
|                         DBGLINE | ||||
| 						poco_information(Logger(), fmt::format("Send email verification link to {}", | ||||
| 															   UInfo.email)); | ||||
| 					} | ||||
|                     DBGLINE | ||||
| 					StorageService()->ActionLinksDB().SentAction(i.id); | ||||
|                     DBGLINE | ||||
| 				} break; | ||||
|  | ||||
| 				case OpenWifi::SecurityObjects::LinkActions::EMAIL_INVITATION: { | ||||
|                     DBGLINE | ||||
| 					if (AuthService()->SendEmailToUser(i.id, UInfo.email, | ||||
| 													   MessagingTemplates::EMAIL_INVITATION)) { | ||||
|                         DBGLINE | ||||
| 						poco_information( | ||||
| 							Logger(), fmt::format("Send new subscriber email invitation link to {}", | ||||
| 												  UInfo.email)); | ||||
| 					} | ||||
|                     DBGLINE | ||||
| 					StorageService()->ActionLinksDB().SentAction(i.id); | ||||
|                     DBGLINE | ||||
| 				} break; | ||||
|  | ||||
| 				case OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD: { | ||||
| 					if (AuthService()->SendEmailToSubUser(i.id, UInfo.email, | ||||
| 														  MessagingTemplates::SUB_FORGOT_PASSWORD,"")) { | ||||
|                         DBGLINE | ||||
| 						poco_information( | ||||
| 							Logger(), | ||||
| 							fmt::format("Send subscriber password reset link to {}", UInfo.email)); | ||||
| 					} | ||||
|                     DBGLINE | ||||
| 					StorageService()->ActionLinksDB().SentAction(i.id); | ||||
|                     DBGLINE | ||||
| 				} break; | ||||
|  | ||||
| 				case OpenWifi::SecurityObjects::LinkActions::SUB_VERIFY_EMAIL: { | ||||
| 					if (AuthService()->SendEmailToSubUser( | ||||
| 							i.id, UInfo.email, MessagingTemplates::SUB_EMAIL_VERIFICATION,"")) { | ||||
|                         DBGLINE | ||||
| 						poco_information( | ||||
| 							Logger(), fmt::format("Send subscriber email verification link to {}", | ||||
| 												  UInfo.email)); | ||||
| 					} | ||||
|                     DBGLINE | ||||
| 					StorageService()->ActionLinksDB().SentAction(i.id); | ||||
|                     DBGLINE | ||||
| 				} break; | ||||
|  | ||||
| 				case OpenWifi::SecurityObjects::LinkActions::SUB_SIGNUP: { | ||||
|                     DBGLINE | ||||
| 					auto Signup = Poco::StringTokenizer(UInfo.signingUp, ":"); | ||||
|                     DBGLINE | ||||
| 					if (AuthService()->SendEmailToSubUser( | ||||
| 							i.id, UInfo.email, MessagingTemplates::SUB_SIGNUP_VERIFICATION, | ||||
| 							Signup.count() == 1 ? "" : Signup[0])) { | ||||
|                         DBGLINE | ||||
| 						poco_information( | ||||
| 							Logger(), | ||||
| 							fmt::format("Send new subscriber email verification link to {}", | ||||
| 										UInfo.email)); | ||||
| 					} | ||||
|                     DBGLINE | ||||
| 					StorageService()->ActionLinksDB().SentAction(i.id); | ||||
|                     DBGLINE | ||||
| 				} break; | ||||
|  | ||||
| 				default: { | ||||
|                     DBGLINE | ||||
| 					StorageService()->ActionLinksDB().SentAction(i.id); | ||||
|                     DBGLINE | ||||
| 				} | ||||
| 				} | ||||
| 			} | ||||
|   | ||||
| @@ -798,12 +798,9 @@ namespace OpenWifi { | ||||
| 										 const std::string &OperatorName) { | ||||
| 		SecurityObjects::UserInfo UInfo; | ||||
|  | ||||
|         DBGLINE | ||||
| 		if (StorageService()->SubDB().GetUserByEmail(Email, UInfo)) { | ||||
| 			switch (Reason) { | ||||
| DBGLINE | ||||
| 			case MessagingTemplates::SUB_FORGOT_PASSWORD: { | ||||
|                 DBGLINE | ||||
| 				MessageAttributes Attrs; | ||||
| 				Attrs[RECIPIENT_EMAIL] = UInfo.email; | ||||
| 				Attrs[LOGO] = GetSubLogoAssetURI(); | ||||
| @@ -812,19 +809,15 @@ DBGLINE | ||||
| 									 "/actionLink?action=sub_password_reset&id=" + LinkId; | ||||
| 				Attrs[ACTION_LINK_HTML] = | ||||
| 					"/api/v1/actionLink?action=sub_password_reset&id=" + LinkId; | ||||
|                 DBGLINE | ||||
| 				SMTPMailerService()->AddSubVars(Attrs); | ||||
|                 DBGLINE | ||||
| 				SMTPMailerService()->SendMessage( | ||||
| 					UInfo.email, | ||||
| 					MessagingTemplates::TemplateName(MessagingTemplates::SUB_FORGOT_PASSWORD, | ||||
| 													 OperatorName), | ||||
| 					Attrs, true); | ||||
|                 DBGLINE | ||||
| 			} break; | ||||
|  | ||||
| 			case MessagingTemplates::SUB_EMAIL_VERIFICATION: { | ||||
|                 DBGLINE | ||||
| 				MessageAttributes Attrs; | ||||
| 				Attrs[RECIPIENT_EMAIL] = UInfo.email; | ||||
| 				Attrs[LOGO] = GetSubLogoAssetURI(); | ||||
| @@ -833,20 +826,16 @@ DBGLINE | ||||
| 									 "/actionLink?action=sub_email_verification&id=" + LinkId; | ||||
| 				Attrs[ACTION_LINK_HTML] = | ||||
| 					"/api/v1/actionLink?action=sub_email_verification&id=" + LinkId; | ||||
|                 DBGLINE | ||||
| 				SMTPMailerService()->AddSubVars(Attrs); | ||||
|                 DBGLINE | ||||
| 				SMTPMailerService()->SendMessage( | ||||
| 					UInfo.email, | ||||
| 					MessagingTemplates::TemplateName(MessagingTemplates::SUB_EMAIL_VERIFICATION, | ||||
| 													 OperatorName), | ||||
| 					Attrs, true); | ||||
| 				UInfo.waitingForEmailCheck = true; | ||||
|                 DBGLINE | ||||
| 			} break; | ||||
|  | ||||
| 			case MessagingTemplates::SUB_SIGNUP_VERIFICATION: { | ||||
|                 DBGLINE | ||||
| 				MessageAttributes Attrs; | ||||
| 				Attrs[RECIPIENT_EMAIL] = UInfo.email; | ||||
| 				Attrs[LOGO] = GetSubLogoAssetURI(); | ||||
| @@ -855,25 +844,20 @@ DBGLINE | ||||
| 									 "/actionLink?action=signup_verification&id=" + LinkId; | ||||
| 				Attrs[ACTION_LINK_HTML] = | ||||
| 					"/api/v1/actionLink?action=signup_verification&id=" + LinkId; | ||||
|                 DBGLINE | ||||
| 				SMTPMailerService()->AddSubVars(Attrs); | ||||
|                 DBGLINE | ||||
| 				SMTPMailerService()->SendMessage( | ||||
| 					UInfo.email, | ||||
| 					MessagingTemplates::TemplateName(MessagingTemplates::SUB_SIGNUP_VERIFICATION, | ||||
| 													 OperatorName), | ||||
| 					Attrs, true); | ||||
| 				UInfo.waitingForEmailCheck = true; | ||||
|                 DBGLINE | ||||
| 			} break; | ||||
|  | ||||
| 			default: | ||||
|                 DBGLINE | ||||
| 				break; | ||||
| 			} | ||||
| 			return true; | ||||
| 		} | ||||
|         DBGLINE | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 stephb9959
					stephb9959