(loginUrl, userName string, token interface{})
| 136 | } |
| 137 | |
| 138 | func saveToken(loginUrl, userName string, token interface{}) { |
| 139 | c := &config.GlobalSmartIdeConfig |
| 140 | if !userIsExit(c.Auths, userName, loginUrl) { |
| 141 | for i := range c.Auths { |
| 142 | c.Auths[i].CurrentUse = false |
| 143 | } |
| 144 | c.Auths = append(c.Auths, model.Auth{ |
| 145 | UserName: userName, |
| 146 | Token: token, |
| 147 | LoginUrl: loginUrl, |
| 148 | CurrentUse: true, |
| 149 | }) |
| 150 | } else { |
| 151 | for i, a := range c.Auths { |
| 152 | if a.UserName == userName && a.LoginUrl == loginUrl { |
| 153 | c.Auths[i].Token = token |
| 154 | c.Auths[i].CurrentUse = true |
| 155 | } else { |
| 156 | c.Auths[i].CurrentUse = false |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | c.SaveConfigYaml() |
| 161 | } |
| 162 | |
| 163 | func userIsExit(auths []model.Auth, username string, loginurl string) bool { |
| 164 | for _, a := range auths { |
no test coverage detected