Authentication update
(msg *ClientComMessage, user *types.User, _ *auth.Rec, remoteAddr string)
| 334 | |
| 335 | // Authentication update |
| 336 | func updateUserAuth(msg *ClientComMessage, user *types.User, _ *auth.Rec, remoteAddr string) error { |
| 337 | authhdl := store.Store.GetLogicalAuthHandler(msg.Acc.Scheme) |
| 338 | if authhdl != nil { |
| 339 | // Request to update auth of an existing account. Only basic & rest auth are currently supported |
| 340 | |
| 341 | // TODO(gene): support adding new auth schemes |
| 342 | |
| 343 | rec, err := authhdl.UpdateRecord(&auth.Rec{Uid: user.Uid(), Tags: user.Tags}, msg.Acc.Secret, remoteAddr) |
| 344 | if err != nil { |
| 345 | return err |
| 346 | } |
| 347 | |
| 348 | // Tags may have been changed by authhdl.UpdateRecord, reset them. |
| 349 | // Can't do much with the error here, logging it but not returning. |
| 350 | if _, err = store.Users.UpdateTags(user.Uid(), nil, nil, rec.Tags); err != nil { |
| 351 | logs.Warn.Println("updateUserAuth tags update failed:", err) |
| 352 | } |
| 353 | return nil |
| 354 | } |
| 355 | |
| 356 | // Invalid or unknown auth scheme |
| 357 | return types.ErrMalformed |
| 358 | } |
| 359 | |
| 360 | // addCreds adds new credentials and re-send validation request for existing ones. |
| 361 | // It also adds credential-defined tags if necessary. |
no test coverage detected
searching dependent graphs…