Compare commits

...

3 Commits

Author SHA1 Message Date
Sosthene
75f5a9a9be Log as client (no verification) 2025-08-11 10:23:57 +02:00
f87f7f747d Merge pull request 'Ignore PassIframeReady event in handleMessage' (#21) from ignore_some_events into dev
All checks were successful
Build and Push to Registry / build-and-push (push) Successful in 3m53s
Reviewed-on: #21
2025-08-11 08:23:15 +00:00
Sosthene
489d0bb5c3 Ignore PassIframeReady event in handleMessage
Ignore more events
2025-08-11 10:12:43 +02:00
2 changed files with 34 additions and 8 deletions

View File

@ -21,6 +21,7 @@ import UserStore from "@Front/Stores/UserStore";
import AuthModal from "src/sdk/AuthModal";
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
import MessageBus from "src/sdk/MessageBus";
export enum LoginStep {
EMAIL,
@ -41,6 +42,7 @@ export default function Login() {
const [totpCode, setTotpCode] = useState<string>("");
const [email, setEmail] = useState<string>("");
const [partialPhoneNumber, setPartialPhoneNumber] = useState<string>("");
const [sessionId, setSessionId] = useState<string>("");
const [validationErrors, setValidationErrors] = useState<ValidationError[]>([]);
const [isAuthModalOpen, setIsAuthModalOpen] = useState(false);
@ -92,10 +94,13 @@ export default function Login() {
// If the code is valid setting it in state
if (res.validCode) {
setTotpCode(values["totpCode"]);
setSessionId(res.sessionId); // Store the session ID
}
*/
if ('1234' === values["totpCode"]) {
setTotpCode(values["totpCode"]);
// For testing, set a mock session ID
setSessionId("mock-session-id-123");
}
setValidationErrors([]);
@ -265,17 +270,38 @@ export default function Login() {
{isAuthModalOpen && <AuthModal
isOpen={isAuthModalOpen}
onClose={() => {
CustomerService.getCustomers().then((processes: any[]) => {
if (processes.length > 0) {
const customers: any[] = processes.map((process: any) => process.processData);
const customer: any = customers.find((customer: any) => customer.contact.email === email);
if (customer) {
UserStore.instance.connect(customer);
// After 4nk authentication is complete, get the process for the pairing ID
MessageBus.getInstance().initMessageListener();
MessageBus.getInstance().isReady().then(async () => {
try {
// Get the pairing ID
const pairingId = await MessageBus.getInstance().getPairingId();
console.log('[Login] Got pairing ID:', pairingId);
// Get all processes
const processes = await MessageBus.getInstance().getProcesses();
console.log('[Login] Got processes:', Object.keys(processes));
const targetProcess = processes[pairingId];
if (targetProcess) {
console.log('[Login] Found target process:', targetProcess);
// Connect the user with the process data
UserStore.instance.connect(targetProcess);
router.push(Module.getInstance().get().modules.pages.Folder.pages.Select.props.path);
} else {
console.error('[Login] No process found for pairing ID:', pairingId);
// Handle the case where no process is found
}
MessageBus.getInstance().destroyMessageListener();
} catch (error) {
console.error('[Login] Error getting process:', error);
MessageBus.getInstance().destroyMessageListener();
}
setIsAuthModalOpen(false);
});
setIsAuthModalOpen(false);
}}
/>}
</div>

View File

@ -881,7 +881,7 @@ export default class MessageBus {
}
private handleMessage(event: MessageEvent): void {
if (!event.data || event.data.type === 'PassClientScriptReady') {
if (!event.data || ['PassClientScriptReady', 'PassIFrameReady', 'Pass::MainWorld::Message', 'Pass::MainWorld::Response'].includes(event.data.type)) {
return;
}