feat: Implement S2A OAuth authorization using chromedp and introduce new files for browser automation and team processing.
This commit is contained in:
@@ -245,11 +245,28 @@ func (r *RodAuth) CompleteOAuthLogged(authURL, email, password, teamID string, l
|
||||
btn.MustClick()
|
||||
}
|
||||
|
||||
time.Sleep(1500 * time.Millisecond)
|
||||
// 等待页面跳转(等待 URL 变化或密码框出现,最多 10 秒)
|
||||
passwordSelector := "input[name='current-password'], input[autocomplete='current-password'], input[type='password'], input[name='password'], input[id='password']"
|
||||
var passwordFound bool
|
||||
for i := 0; i < 20; i++ {
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
if code := r.checkForCode(page); code != "" {
|
||||
logStep(StepComplete, "授权成功")
|
||||
return code, nil
|
||||
if code := r.checkForCode(page); code != "" {
|
||||
logStep(StepComplete, "授权成功")
|
||||
return code, nil
|
||||
}
|
||||
|
||||
info, _ = page.Info()
|
||||
// 检查是否有密码输入框(页面已跳转)
|
||||
if pwdInput, _ := page.Timeout(100 * time.Millisecond).Element(passwordSelector); pwdInput != nil {
|
||||
passwordFound = true
|
||||
break
|
||||
}
|
||||
|
||||
// 如果 URL 已经变化(包含 password),也跳出
|
||||
if strings.Contains(info.URL, "password") {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前URL用于调试
|
||||
@@ -257,7 +274,12 @@ func (r *RodAuth) CompleteOAuthLogged(authURL, email, password, teamID string, l
|
||||
logStep(StepInputPassword, "查找密码框 | URL: %s", info.URL)
|
||||
|
||||
// 使用10秒超时查找密码输入框(优先使用 current-password)
|
||||
passwordInput, err := page.Timeout(10 * time.Second).Element("input[name='current-password'], input[autocomplete='current-password'], input[type='password'], input[name='password'], input[id='password']")
|
||||
var passwordInput *rod.Element
|
||||
if passwordFound {
|
||||
passwordInput, err = page.Timeout(2 * time.Second).Element(passwordSelector)
|
||||
} else {
|
||||
passwordInput, err = page.Timeout(10 * time.Second).Element(passwordSelector)
|
||||
}
|
||||
if err != nil {
|
||||
info, _ := page.Info()
|
||||
logError(StepInputPassword, "未找到密码输入框 | URL: %s", info.URL)
|
||||
|
||||
Reference in New Issue
Block a user