add support for Trusted to rest-auth

This commit is contained in:
or-else
2022-05-11 09:17:30 -07:00
parent 028f6aa42d
commit da6cc5271e
2 changed files with 12 additions and 7 deletions
+6 -4
View File
@@ -120,8 +120,9 @@ add logical renaming and disable `rest` at the original name:
// Default access mode
"auth": "JRWPS",
"anon": "N",
"public": {...}, // user's public data, see /docs/API.md#public-and-private-fields
"private": {...} // user's private data, see /docs/API.md#public-and-private-fields
"public": {...}, // user's public data, see /docs/API.md#trusted-public-and-private-fields
"trusted": {...}, // user's trusted data, see /docs/API.md#trusted-public-and-private-fields
"private": {...} // user's private data, see /docs/API.md#trusted-public-and-private-fields
}
}
```
@@ -222,8 +223,9 @@ be used by client (Tinode) to create the account. The server may optionally retu
"newacc": {
"auth": "JRWPS",
"anon": "N",
"public": {/* see /docs/API.md#public-and-private-fields */},
"private": {/* see /docs/API.md#public-and-private-fields */}
"public": {/* see /docs/API.md#trusted-public-and-private-fields */},
"trusted": {/* see /docs/API.md#trusted-public-and-private-fields */},
"private": {/* see /docs/API.md#trusted-public-and-private-fields */}
}
}
```
+6 -3
View File
@@ -50,6 +50,8 @@ type newAccount struct {
Anon string `json:"anon,omitempty"`
// User's Public data
Public interface{} `json:"public,omitempty"`
// User's Trusted data
Trusted interface{} `json:"trusted,omitempty"`
// Per-subscription private data
Private interface{} `json:"private,omitempty"`
}
@@ -206,9 +208,10 @@ func (a *authenticator) Authenticate(secret []byte, remoteAddr string) (*auth.Re
// Create account, get UID, report UID back to the server.
user := types.User{
State: resp.Record.State,
Public: resp.NewAcc.Public,
Tags: resp.Record.Tags,
State: resp.Record.State,
Public: resp.NewAcc.Public,
Trusted: resp.NewAcc.Trusted,
Tags: resp.Record.Tags,
}
user.Access.Auth.UnmarshalText([]byte(resp.NewAcc.Auth))
user.Access.Anon.UnmarshalText([]byte(resp.NewAcc.Anon))