MCPcopy Index your code
hub / github.com/coder/coder / ConvertUser

Function ConvertUser

coderd/telemetry/telemetry.go:1420–1438  ·  view source on GitHub ↗

ConvertUser anonymizes a user.

(dbUser database.User)

Source from the content-addressed store, hash-verified

1418
1419// ConvertUser anonymizes a user.
1420func ConvertUser(dbUser database.User) User {
1421 emailHashed := ""
1422 atSymbol := strings.LastIndex(dbUser.Email, "@")
1423 if atSymbol >= 0 {
1424 // We hash the beginning of the user to allow for indexing users
1425 // by email between deployments.
1426 hash := sha256.Sum256([]byte(dbUser.Email[:atSymbol]))
1427 emailHashed = fmt.Sprintf("%x%s", hash[:], dbUser.Email[atSymbol:])
1428 }
1429 return User{
1430 ID: dbUser.ID,
1431 EmailHashed: emailHashed,
1432 RBACRoles: dbUser.RBACRoles,
1433 CreatedAt: dbUser.CreatedAt,
1434 Status: dbUser.Status,
1435 GithubComUserID: dbUser.GithubComUserID.Int64,
1436 LoginType: string(dbUser.LoginType),
1437 }
1438}
1439
1440func ConvertGroup(group database.Group) Group {
1441 return Group{

Callers 4

postFirstUserMethod · 0.92
postUserMethod · 0.92
oauthLoginMethod · 0.92
createSnapshotMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected