Facebook said its engineers discovered a security weakness this week that could let attackers hijack people’s accounts. The vulnerability, which the company said had been fixed, affected nearly 50 million accounts.

Facebook said in a web post that the security issue was related to the “View As” feature, which allows people to see a preview of what their profile looks like to other people, like specific friends. Hackers exploited a weakness in the tool to gain access to digital keys that let people access Facebook from a personal device without having to re-enter a password. The keys could then be used to take over people’s accounts, the company said.

The social networking giant said that it had reset all the access keys for affected users and that those users would have to log back into their accounts. In other words, there is not much you have to do. But there are some precautions you should take to protect yourself from the attack.

Do a Device Audit

The best way to determine whether someone has gained improper access to your account is to do an audit of the devices that you have used to log in to Facebook. On Facebook’s Security and Login page, under the tab labeled “Where You’re Logged in,” you can see a list of devices that are signed into your account, as well as their locations. If you see an unfamiliar gadget or a device signed in at an odd location, you can click the “Remove” button to boot the device out of your account.

Change Your Password

Facebook says that because it has fixed the vulnerability, there is no need to change your account password. But to be extra safe, you probably should anyway — especially if you use a weak password or saw any suspicious devices logged into your accounts.

If you decide to change your password, choose a complex one — and do not reuse a password you have used on a different site. Try creating long and complex passwords consisting of nonsensical phrases or one-sentence summaries of strange life events and add numbers and special characters, like: My favorite number is Green4782#.

To keep your passwords organized and easy to access, consider using a password-management app like 1Password or LastPass. These tools let you keep all your passwords in a digital vault that can be opened with one master password, and they can also automatically generate complex passwords.

Turn on Two-Factor Authentication

Like many sites, Facebook offers a security feature called two-factor authentication. It involves text messaging a unique code to your phone that you must type in after entering your password. This way, even if someone gained access to your password, it would be difficult to log in without that code. Even though Facebook fixed this week’s security vulnerability, every user should have this feature turned on.