参数
nomstring姓 姓 姓 姓 姓 姓 姓 姓 姓
prenomstring名声
genrestring账户上公布
telstring电话号码
adressestring街口地址 街口 街口 街口
villestring城市
六个字段, 其它东西都无法在此写入。 电子邮件、 密码和平衡不公开 SDK 业务。
部分更新
发送一个字段和一个字段的更改。 不需要先读取配置文件, 也不必写回其它文件的残本 。
await api.auth.updateProfile({ ville: "Tunis" });
// everything else is exactly as it wasapi.auth.update_profile({"ville": "Tunis"})
# everything else is exactly as it was空值被降低, 不应用
应用前更新时从空抵达的字段中删除。所以发送 "" 并不清晰一个领域——它没有改变任何东西,呼吁仍然答案 ok。无法通过这种方法将配置字段空白。
await api.auth.updateProfile({ ville: "" });
// { ok: true, … } — and "ville" is unchanged
await api.auth.updateProfile({ tel: null });
// the same: nothing is clearedapi.auth.update_profile({"ville": ""})
# {"ok": True, ...} — and "ville" is unchanged
api.auth.update_profile({"tel": None})
# the same: nothing is cleared提交空白的表格不会按表格上所写的那样
未保存的输入会张贴空字符串, 此处忽略空字符串。 只发送用户实际编辑过的字段, 否则页面会报告一个没有发生的更改 。
// Build the patch from what changed, not from the whole form
const patch = {};
for (const [field, value] of Object.entries(form)) {
if (value !== "" && value !== original[field]) patch[field] = value;
}
if (Object.keys(patch).length) await api.auth.updateProfile(patch);# Build the patch from what changed, not from the whole form
patch = {field: value for field, value in form.items()
if value != "" and value != original.get(field)}
if patch:
api.auth.update_profile(patch)账户设置中的密码更改
A 音 A API 键可以更新配置配置元数据, 因此它永远不能替换账户的证书。 传递 password 被本地端的 SDK 和《公约》 API 与 password_change_private。使用签名账户设置代替。
返回值
服务器现在的账户, 由服务器的账户持有, 密码被解开。 这是完整记录, 比四个字段宽 $User () 将其缩小到——阅读它以确认已实现的变更,而不是作为依赖的合同。
const { ok, user } = await api.auth.updateProfile({ ville: "Tunis" });
ok; // true
user.ville; // "Tunis" — confirmation
// Everything else on `user` is the account record. Treat it as informational.answer = api.auth.update_profile({"ville": "Tunis"})
answer["ok"] # True
answer["user"]["ville"] # "Tunis" — confirmation
# Everything else on "user" is the account record. Treat it as informational.错误
| 代码 | 状态 | 触发条件 |
|---|---|---|
| 未经授权 | 401 | 调用时没有有效的会话或密钥 。 |
| password_change_private | 403 | 要求通过公众更改密码 SDK. |
| user_not_found | 404 | 届会将点指向一个不再存在的账户。 |
一件值得首先考虑的事
这些是个人细节,它们是账户持有人的。 写他们的程序应该是因为有人要求这样做,他们给的有价值——而不是因为碰巧有它们就从其他地方抄过来。