MCPcopy
hub / github.com/tinode/chat / updateUserAuth

Function updateUserAuth

server/user.go:336–358  ·  view source on GitHub ↗

Authentication update

(msg *ClientComMessage, user *types.User, _ *auth.Rec, remoteAddr string)

Source from the content-addressed store, hash-verified

334
335// Authentication update
336func 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.

Callers 1

replyUpdateUserFunction · 0.85

Calls 5

UidMethod · 0.80
PrintlnMethod · 0.80
GetLogicalAuthHandlerMethod · 0.65
UpdateRecordMethod · 0.65
UpdateTagsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…