MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / saveToken

Function saveToken

cli/cmd/login.go:138–161  ·  view source on GitHub ↗
(loginUrl, userName string, token interface{})

Source from the content-addressed store, hash-verified

136}
137
138func 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
163func userIsExit(auths []model.Auth, username string, loginurl string) bool {
164 for _, a := range auths {

Callers 2

loginAndSaveTokenFunction · 0.85

Calls 2

userIsExitFunction · 0.85
SaveConfigYamlMethod · 0.80

Tested by

no test coverage detected