返回 DeepSeek-Reasonix
authentication_app.go
根目录 / desktop / authentication_app.go
1 package main
2
3 import (
4 "fmt"
5
6 "reasonix/internal/control"
7 )
8
9 // RetryAuthenticationForTab authorizes one explicit request attempt for a
10 // credential that the current controller generation previously rejected. It
11 // never replays a failed turn.
12 func (a *App) RetryAuthenticationForTab(tabID string) (control.AuthenticationState, error) {
13 a.runtimeRebuildMu.Lock()
14 tab, ctrl := a.tabAndCtrlByID(tabID)
15 defer func() {
16 a.runtimeRebuildMu.Unlock()
17 a.refreshTabMetaExtras(tab)
18 }()
19 if tab == nil {
20 return control.AuthenticationState{}, fmt.Errorf("session is unavailable")
21 }
22 tab.turnStartMu.Lock()
23 defer tab.turnStartMu.Unlock()
24 if a.tabIsReadOnly(tab) {
25 return control.AuthenticationState{}, readOnlyChannelErr()
26 }
27 if err := a.workspaceRuntimeAdmissionErr(tab, ctrl); err != nil {
28 return control.AuthenticationState{}, err
29 }
30 retry, ok := ctrl.(interface {
31 AuthenticationState() control.AuthenticationState
32 RetryAuthentication() bool
33 })
34 if !ok {
35 return control.AuthenticationState{}, fmt.Errorf("authentication retry is unavailable for this session")
36 }
37 state := retry.AuthenticationState()
38 if !retry.RetryAuthentication() {
39 return state, fmt.Errorf("authentication retry is only available after a rejected credential")
40 }
41 return retry.AuthenticationState(), nil
42 }
43
43 lines GO