mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
fix(auth): make logout reject only the credential tea stored
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
6 files changed
+50
-28
No files matched your search
@@ -709,7 +709,7 @@ instance, such as a copy of its token that a keychain kept after a push.`,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
account, exists := t.host.Users[t.User]
|
||||
_, exists := t.host.Users[t.User]
|
||||
switch {
|
||||
case len(t.host.Users) == 0:
|
||||
return clierr.Wrap(clierr.Usage, fmt.Errorf("not logged in to %s", t.Host))
|
||||
@@ -725,14 +725,14 @@ instance, such as a copy of its token that a keychain kept after a push.`,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := manager.Logout(t.Host, t.User); err != nil {
|
||||
removed, err := manager.Logout(t.Host, t.User)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.done(cmd, "Logged out of %s (%s)", t.Host, t.User)
|
||||
if !account.Tokenless() {
|
||||
if err := git.RejectCredentials(cmd.Context(), a.gitProbe(), a.options.cwd, t.Host, t.User); err != nil {
|
||||
a.warn(cmd, "Could not ask git's credential helpers to forget %s on %s", t.User, t.Host)
|
||||
}
|
||||
// Helpers erase only the copies that hold the removed token, not the user's own credentials.
|
||||
if err := git.RejectCredentials(cmd.Context(), a.gitProbe(), a.options.cwd, t.Host, t.User, removed.AccessToken); err != nil {
|
||||
a.warn(cmd, "Could not ask git's credential helpers to forget %s on %s", t.User, t.Host)
|
||||
}
|
||||
if s, err := a.settings(); err == nil {
|
||||
if active := s.Hosts.Hosts[t.Host].User; active != "" && active != t.host.User {
|
||||
|
||||
Reference in new issue
Block a user