Remembering login session when logging in with username/password?
Currently gtkcord4 does not remember your username/password or the resulting token. Looking at https://github.com/diamondburned/gtkcord4/blob/main/internal/gtkcord/window/login/component.go, only loginToken() calls SecretDriver().Set(), and loginEmail() does not.
Can the code be changed to remember to remember the generated token (and possibly username/password though not 2FA code, in case the token expires)?
(Is this something straightforward enough for me to contribute a PR, or is it architecturally complex enough for you to do it yourself?)
Currently gtkcord4 does not remember your username/password or the resulting token.
It does. After the username and password are given, the returned token is stored. That's why there's a Remember Me checkbox for both Username/Password and Token logins.
the returned token is stored
I tried logging in in gtkcord4. After opening Seahorse (Passwords and Keys), it showed the only password saved by gtkcord4 is __secret_available_000 from Keyring::IsAvailable(). No token is saved. (Incidentally when I try running gtkcord4 in a terminal, I see a message note: account not found from driver: key not found. I think all this means is that no saved token was found.)
Why is that? Only login() → loginToken() calls:
driver := c.Remember.SecretDriver()
...
driver.Set("account", []byte(token))
...
c.page.asyncUseToken(token)
Whereas login() → loginEmail() calls gtkutil.Async() (not sure exactly what that does, but I'd have to figure out to make a PR) running:
u, err := session.Login(c.ctx, email, password, totp)
...
return func() {
c.page.asyncUseToken(u.Token)
with no call to driver.Set("account", []byte(u.Token));, nor a call to loginToken().
Unless my observations and code reading are mistaken, the "Remember Me" checkbox is a no-op in Username/Password mode. Did I make an error somewhere in my reading?
I think you're right. Perhaps component.go:186 should be calling c.loginToken.
Can you test that and see if it works?
How would I test the change locally?
Editing ~/go/... failed to save the file. I tried cloning gtkcord4 and editing that, then ran go install -v ., and now it's busy burning 1 of 2 of my old CPU cores on gcc (it would be a lot more wasteful on my modern 12-thread CPU where I run Electron Discord rather than gtkcord4 on), and it looks like parallelization is an open issue. (EDIT: After the build finished, email login saves the password properly.)
Apparently it's building github.com/diamondburned/gotk4/pkg/gdk/v4 and friends a second time, after I've already waited half an hour yesterday on go install -v github.com/diamondburned/gtkcord4@latest, which already built the same packages. Why is it doing this?
(In theory, if the bug lied in a dependency, what would be the best way to patch it locally? Manually downloading the dependency, then adding a "replace" statement in go.mod (not much better than Cargo)?)
and now it's busy burning 1 of 2 of my old CPU cores on gcc (it would be a lot more wasteful on my modern 12-thread CPU where I run Electron Discord rather than gtkcord4 on),
You can use the patched Go compiler. See gotk4-nix.
Apparently it's building
github.com/diamondburned/gotk4/pkg/gdk/v4and friends a second time, after I've already waited half an hour yesterday ongo install -v github.com/diamondburned/gtkcord4@latest, which already built the same packages. Why is it doing this?
@latest fetches v0.0.3. git cloneing fetches the head commit.
(In theory, if the bug lied in a dependency, what would be the best way to patch it locally? Manually downloading the dependency, then adding a "replace" statement in go.mod (not much better than Cargo)?)
Yes.
I have this issue too.
I am also having the same issue
Samsies! #metoo
Potentially fixed in c6c0aab.
#141 Might be a duplicate of this issue