aarondoet / AccountSwitcher

BetterDiscord plugin to switch between multiple accounts
MIT License
229 stars 79 forks source link

[Issue] Can't switch to acc with 2 factor auth #14

Open PurpleDxD opened 4 years ago

PurpleDxD commented 4 years ago

Describe the bug Tries to switch to account with 2 factor auth but doesn't get passed the login screen

To Reproduce Steps to reproduce the behavior: Switch to account with 2 factor auth enabled

Expected behavior Account should switch

Information (please complete the following information):

aarondoet commented 4 years ago

It should work. Try saving the account again, maybe there was some problem when saving it.

Mirrored6 commented 4 years ago

Describe the bug Tries to switch to account with 2 factor auth but doesn't get passed the login screen

To Reproduce Steps to reproduce the behavior: Switch to account with 2 factor auth enabled

Expected behavior Account should switch

Information (please complete the following information):

* OS: Win 10

* Plugin Version: Latest

* Discord version: Stable

* Compact Mode enabled? no

* Encryption enabled? yes

It also doesn't work for me. i can switch from 2fa accounts to non 2fa accounts, but not from non 2fa accounts to 2fa accounts. or from 2fa account to 2fa accounts

i use the same settings as the guy before.

aarondoet commented 4 years ago

did you also try saving the 2fa account again?

Mirrored6 commented 4 years ago

yes. and it didn't work. saddly

aarondoet commented 4 years ago

I asked again in my server and I was told that switching to accounts with 2fa works. And I really don't know why it should work for accounts without 2fa but not for accounts with 2fa.

z-e-x commented 4 years ago

I'm experiencing the same issues as the people above. I've also tried saving again too. Only switching between accounts without 2FA work or switching from 2FA to non 2FA accounts.

aarondoet commented 4 years ago

What the f... I don't understand why and I have no clue why this could be the case

muropakett commented 4 years ago

could the problem be on his end? and not the plugin also when i enabled 2fa i got the same bug but fixed it by simply removing the account from the plugin and saving again

z-e-x commented 4 years ago

For me, I've tried saving it multiple times and it didn't work. I've been using accountswitcher since 9/24/2019 and haven't been able to get it to work with 2fa at all and I've tried multiple times.

muropakett commented 4 years ago

remove the plugin and reinstall?

z-e-x commented 4 years ago

I tried that earlier, still the same issue. I'm gonna try a third time and see if I can get it to work.

muropakett commented 4 years ago

alright

z-e-x commented 4 years ago

It must've been something with my previous file. I removed the plugin but noticed the settings were staying the same because I wasn't reloading Discord (I think that's why). After reloading a couple times after every change I saved the 2fa account again and it's working fine.

muropakett commented 4 years ago

good that its working now

xenorio commented 4 years ago

Same behavior here. When switching to a 2fa protected account, the login page shows up. After disabling 2fa for that account everything works as expected again. So it's definitely a problem with 2fa.

aarondoet commented 4 years ago

I want to check if there are similarities between you all. Please add a reaction based on your settings:

:+1: Encryption enabled :-1: Encryption disabled

:heart: Discord Stable :rocket: Discord Canary :eyes: Discord PTB

muropakett commented 4 years ago

it cant be 2fa because i got it enabled and it works just fine

xenorio commented 4 years ago

@muropakett great that it works for you. but when something doesn't work, you change one single variable (whether or not 2fa is enabled) and it suddenly works fine, logic would suggest that this variable is the reason for it not working. could be that it's a bug that only happens on specific systems, could be that you're just lucky. but fact is that with 2fa enabled i can't switch accounts, but when i disable it i can. i have even reproduced this multiple times now, even on different discord versions (stable and canary), so this is not some weird random one-off anomaly.

aarondoet commented 4 years ago

When it is working for many people, removing and adding the account does not help and nobody can give me hints on why it might not be working I can't help. I can't reproduce it, many people can't reproduce it and those who have the problem can't (or at least they did not) give me any information that could help me.

xenorio commented 4 years ago

Well, what information would be relevant? I tested it on Discord stable and canary, i'm using Pop!_OS 19.04 (Ubuntu based) with x64 architecture and i3wm instead of gnome, i have the latest versions of BetterDiscord and this plugin installed, the Discord account i tested it with has Nitro, i can log in without any issues, and i can use the Discord API directly with the user token

aarondoet commented 4 years ago

The problem is that I don't really know what information could be useful since everything I thought that might be useful does not seem to be important. I might get some hints when being able to test it on my own and playing around with stuff, but that is very hard to do when I can't reproduce it. And I don't want to ask people to give me remote control over their computer and let me test stuff with their token.

muropakett commented 4 years ago

hmm shouldnt u ask xenorio to send some parts of the console and ask the same parts from someone whos account switcher works with 2fa

muropakett commented 4 years ago

idk if that would work but still

legitatx commented 4 years ago

Hey guys, I managed to fix the issue. So, when I first saved the account with 2FA, I had encryption disabled. Like everyone above, my second account was saved without 2FA. With encryption disabled, I was able to switch to my non-2FA account without logging in again, but with my 2FA account, I wasn't able to get past the login screen when switching back again.

The fix for me was removing all the accounts I had already saved. Then, I enabled encryption and set the password using the instructions provided (in the Developer Tools). After that, I saved all the accounts again, and was able to transfer between 2FA and non-2FA accounts just fine without having to relog every time.

Hope this helps!

aarondoet commented 4 years ago

The function to manually set the password in the console will always return undefined. It will just perform the process of you typing that password in the popout because that does not work atm.

cyberrrr commented 4 years ago

I had the same issue.

What I did, was remove the account from the Plugins tab, then add it again. That solved the issue for me!

React if this worked.

murl-digital commented 3 years ago

im having the same issue, and none of the mentioned steps above have worked, so i thought id provide the loglines if its any help image

chocoearly44 commented 3 years ago

I have the same issue now. I have 2FA on 2nd account and I get prompted with a login screen.

Edit: I just saved the 2FA account as secondary and now it works fine.

Neko-LoverDisc commented 3 years ago

Same issue

C0D3-M4513R commented 3 years ago

initital startup is always working fine. After switching and switching back, it doesn't work. Something is different between the discord auth machanism, and this mechanism? Is there a way to use the discord builtin auth mechanism, to auth a account? EDIT: The Solution really seems to just save the account multiple times.

ghost commented 3 years ago

I had the same problem. I fixed it by just removing and adding the account a few times. Weird.

xero-lib commented 3 years ago

The most common cause of this that I've seen is that the discord sometimes stores the mfa. value in the keyvalue pair for the token in a separate state object, and is not read by the account switcher during saves.

Solution: prepend mfa. to your token in the account list.

aarondoet commented 3 years ago

The most common cause of this that I've seen is that the discord sometimes stores the mfa. value in the keyvalue pair for the token in a separate state object, and is not read by the account switcher during saves.

Solution: prepend mfa. to your token in the account list.

I've never seen this happening. If that actually is the case I could make a fix by just appending it when 2fa is enabled and it does not start with that. Since tokens always are encrypted in the settings file where they are stored you can't just add it yourself tho.

aarondoet commented 3 years ago

To those with this issue, can you open the devtools (Ctrl+Shift+I), go to the console tab, paste the following snipped and then tell me what the output is? It should either be true or false. If you get anything else that is neither true nor false please DO NOT post the result here and make sure you actually copied/pasted the whole thing.

ZeresPluginLibrary.WebpackModules.getByProps("getToken").getToken().startsWith("mfa")

Also: Only tell me the result for accounts that are using 2FA!

xenorio commented 3 years ago

it's returning true

cyberrrr commented 3 years ago

true

Tjird commented 3 years ago

true for me also

aarondoet commented 3 years ago

I just saw I did not post this here yet, only on my discord server:

AccountSwitcher Troubleshooting Guide This guide is for people who need to log in again after switching accounts using AccountSwitcher.

Remove the account in the AccountSwitcher settings and then add it again. Try switching the account, if it does not work then continue.  Remove the account in the AccountSwitcher settings, disable 2FA for the account and then enable it again. Add the account again in the plugin settings. If switching still does not work, try changing the password of your account. Then remove and add it again in the settings.  After following the guide the plugin should work correctly for most people. Only a few people with 2FA enabled still have issues. I have no clue why and nobody could tell me why. Since it is dealing with tokens it is hard to get help from others because I'd at least need additional account tokens which would give me access to the account. Thus it is a problem I can't really fix. I'd recommend not turning off 2FA just so that you can use the plugin.

FeelsBadMan1 commented 3 years ago

Hello, i have a simillar issure that has to do with 2fa i think too. if i switch from account1 to account2 or account3 or account4 etc. then it will loading a while and after 1 - 5 seconds im logged in into the account i switched to. then it takes 2 seconds and the discordclient randomly closing. After reopen the Client im sucessfully logged in without a closing Client anymore. However its annoying to restart the Client between each switch so it would be nice if there is any fix for this.

TimWelm commented 3 years ago

I fixed this when I set the account with the 2fa code to the second save. So now the account without 2fa is in my first slot and the account with 2fa is in the second slot. This worked for me, hope it helps others too!

KineticAeon commented 3 years ago

The above seems to be correct, the first slot seems to have an issue with 2fa accounts for some reason. Edit: Nevermind, didn't work after the second switch and adding another account. Update: It now works through multiple switches, but it has to be in the last slot.

aarondoet commented 3 years ago

I think I got new insight into this recently, something I did not know before. When you have 2FA enabled then your token will expire when you log out. Switching account does not log you out, it only replaces your current token so that should not be an issue. However, logging out to then add another account causes this issue. First add all your accounts that do not have 2FA enabled and then add your 2FA account as the last one. I think to log out without causing the token to expire you can also open the dev tools (Ctrl+Shift+I), then open the Console tab and then execute this: ZeresPluginLibrary.WebpackModules.getByProps("loginToken").loginToken("").

Aquadraws commented 3 years ago

I think I got new insight into this recently, something I did not know before. When you have 2FA enabled then your token will expire when you log out. Switching account does not log you out, it only replaces your current token so that should not be an issue. However, logging out to then add another account causes this issue. First add all your accounts that do not have 2FA enabled and then add your 2FA account as the last one. I think to log out without causing the token to expire you can also open the dev tools (Ctrl+Shift+I), then open the Console tab and then execute this: ZeresPluginLibrary.WebpackModules.getByProps("loginToken").loginToken("").

I can confirm about the token expiring when clicking "Log Out" (Tried today). So I added my first account (with 2FA, I got 4, with 2FA enabled), ran ZeresPluginLibrary.WebpackModules.getByProps("loginToken").loginToken(""). logged in the other account and repeated the process for the others. Now I can switch fine.

luximus-hunter commented 3 years ago

I can confirm about the token expiring when clicking "Log Out" (Tried today). So I added my first account (with 2FA, I got 4, with 2FA enabled), ran ZeresPluginLibrary.WebpackModules.getByProps("loginToken").loginToken(""). logged in the other account and repeated the process for the others. Now I can switch fine.

I might be a complete idiot, but this didn't work for me with my 2 accounts with 2fa. Does logging in with the QR code matter?