What you describe resembles a scam, and since you already provided your Mac's login credentials to it, it can be assumed all the information on your Mac has already been harvested, uploaded, sold, etc and should be considered in the wind.
First and most fundamental question: Do you have a Time Machine backup that you can restore, one that was created prior to the appearance of that dialog box? If so, restore it, and confirm the dialog box does not return: Restore your Mac from a backup - Apple Support
If not, read on.
Your task is now to identify and get rid of whatever it is that came to be installed on your Mac. Until then, it will remain active doing whatever it does, and there is no way to determine what that might be.
Assuming that dialog box cannot be dismissed (you merely dragged it out of sight) first try restarting your Mac in the usual manner. If you are unable to restart it normally due to the presence of that dialog, force your Mac to restart be pressing and holding its power button until it shuts down. Then, release the power button, and start your Mac again.
The intrusive dialog may or may not reappear, but whether or not that dialog reappears after restarting your Mac, the intrusion may still be active. The best way to possibly identify the intrusion would be to download and run EtreCheck, then post its report in a reply to this Discussion. Instructions are here: How to use the Add Text Feature When Posting Large Amounts of Text, i.e. an Etrecheck Report - Apple Community. Once you post that report, we can examine it for possible clues and recommend remedial action.
EtreCheck is written for non tech-savvy people but if you have any questions regarding how to use it or how to post its report in a reply, by all means write back for help.