Nhảy đến nội dung

updateUser

Cập nhật một đối tượng người dùng đơn lẻ. 🔐 Phương thức này yêu cầu ủy quyền.

Mô tả

Phương thức này cập nhật đối tượng dữ liệu của người dùng đã được ủy quyền. Nó trả về một Promise mà khi hoàn thành sẽ trả về một đối tượng IUserEntity.

Users.updateUser(

body*, body.formIdentifier*, body.langCode, body.authData, body.formData, body.notificationData, body.state, langCode

);

Sơ đồ tham số

Sơ đồ

body(bắt buộc): IUserBody
Nội dung yêu cầu
ví dụ:

{
"formIdentifier": "reg",
"authData": [
{
"marker": "email_reg",
"value": "your-email@oneentery.cloud"
},
{
"marker": "password_reg",
"value": "12345"
}
],
"formData": [
{
"marker": "last_name",
"type": "string",
"value": "Username"
}
],
"notificationData": {
"email": "example@oneentry.cloud",
"phonePush": [
"+99999999999"
],
"phoneSMS": "+99999999999"
},
"state": {}
}

body.formIdentifier(bắt buộc): string
Định danh văn bản của biểu mẫu.
ví dụ: "form_12345"

body.langCode: string
Mã ngôn ngữ cho việc địa phương hóa. Mặc định: "en_US".

body.authData: IAuthData[]
Mảng các đối tượng dữ liệu xác thực với các dấu hiệu và giá trị.
ví dụ:

[
{
"marker": "password",
"value": "12345"
}
]

authData.marker(bắt buộc): string
Dấu hiệu xác định trường xác thực.
ví dụ: "login"

authData.value(bắt buộc): string
Giá trị của trường xác thực.
ví dụ: .com"

body.formData: IAuthFormData | IAuthFormData[]
Đối tượng dữ liệu biểu mẫu hoặc mảng các đối tượng dữ liệu biểu mẫu.
ví dụ:

[
{
"marker": "first_name",
"type": "string",
"value": "John"
},
{
"marker": "last_name",
"type": "string",
"value": "Doe"
}
]

formData.marker(bắt buộc): string
Một định danh duy nhất cho trường biểu mẫu.
ví dụ: "email"

formData.type(bắt buộc): string
Loại của trường biểu mẫu, chẳng hạn như 'string', 'email', v.v.
ví dụ: "string"

formData.value(bắt buộc): string
Giá trị được nhập vào trường biểu mẫu.
ví dụ: "example@oneentry.cloud"

body.notificationData: object
Đối tượng chứa dữ liệu thông báo, bao gồm thông tin email và điện thoại.
ví dụ:

{
"email": "example@oneentry.cloud",
"phonePush": [
"+99999999999"
],
"phoneSMS": "+99999999999"
}

body.state: object
Đối tượng chứa thông tin trạng thái bổ sung.
ví dụ:

{
"key": "value"
}

langCode: string
Mã ngôn ngữ. Mặc định: "en_US"
ví dụ: "en_US"

Ví dụ

Ví dụ tối thiểu


await AuthProvider.auth(
"email",
{
"authData": [
{
"marker": "email_reg",
"value": "your@email.com",
},
{
"marker": "password_reg",
"value": "yourPassword"
}
]
}
);

const body = {
"formIdentifier": "reg",
"authData": [
{
"marker": "password",
"value": "yourPassword"
}
],
"formData": [
{
"marker": "last_name",
"type": "string",
"value": "Username"
}
],
"notificationData": {
"email": "example@oneentry.cloud",
"phonePush": ["+99999999999"],
"phoneSMS": "+99999999999"
},
"state": {}
};

const response = await Users.updateUser(body);

Ví dụ cho tham số body với các loại dữ liệu khác nhau

Ví dụ với thuộc tính kiểu đơn giản "string", "integer", "float"

const body = {
"formIdentifier": "reg",
"authData": [
{
"marker": "login",
"value": "test"
},
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "last_name",
"type": "string",
"value": "Федор Иванов"
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
},
"state": {}
};

const response = await Users.updateUser(body);

Ví dụ với các thuộc tính kiểu "date", "dateTime", "time"

const body = {
"formIdentifier": "reg",
"authData": [
{
"marker": "login",
"value": "test"
},
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "birthday",
"type": "date",
"value": {
"fullDate": "2024-05-07T21:02:00.000Z",
"formattedValue": "08-05-2024 00:02",
"formatString": "DD-MM-YYYY HH:mm"
}
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
};

const response = await Users.updateUser(body);

Ví dụ với thuộc tính kiểu "text"

const body = {
"formIdentifier": "reg",
"authData": [
{
"marker": "login",
"value": "test"
},
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "about",
"type": "text",
"value": {
"htmlValue": "<p>Это я</p>",
"plainValue": "Это я",
"mdValue": "*Это я*",
"params": {
"isImageCompressed": true,
"editorMode": "html"
}
}
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
};

const response = await Users.updateUser(body);

Ví dụ với thuộc tính kiểu "textWithHeader"

const body = {
"formIdentifier": "reg",
"authData": [
{
"marker": "login",
"value": "test"
},
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "about",
"type": "textWithHeader",
"value": {
"header": "Заголовок",
"htmlValue": "<p>Это я</p>",
"plainValue": "Это я",
"mdValue": "*Это я*",
"params": {
"isImageCompressed": true,
"editorMode": "html"
}
}
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
};

const response = await Users.updateUser(body);

Ví dụ với các thuộc tính kiểu "image" và "groupOfImages"

const body = {
"formIdentifier": "reg",
"authData": [
{
"marker": "login",
"value": "test"
},
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "avatar",
"type": "image",
"value": [
{
"filename": "files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"downloadLink": "http://my-site.com/cloud-static/files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"size": 392585,
"previewLink": "",
"params": {
"isImageCompressed": true
}
}
]
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
};

const response = await Users.updateUser(body);

Ví dụ với thuộc tính kiểu "file"

const body = {
"formIdentifier": "reg",
"authData": [
{
"marker": "login",
"value": "test"
},
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "picture",
"type": "file",
"value": [
{
"filename": "files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"downloadLink": "http://my-site.com/cloud-static/files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"size": 392585
}
]
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
};

const response = await Users.updateUser(body);

Ví dụ với thuộc tính kiểu "radioButton"

const body = {
"formIdentifier": "reg",
"authData": [
{
"marker": "login",
"value": "test"
},
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "selector",
"type": "radioButton",
"value": {
"title": "red",
"value": "1",
"extended": {
"value": "красный",
"type": "string"
}
}
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
};

const response = await Users.updateUser(body);

Ví dụ với thuộc tính kiểu "list"

const body = {
"formIdentifier": "reg",
"authData": [
{
"marker": "login",
"value": "test"
},
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "selector",
"type": "list",
"value": [
{
"title": "red",
"value": "1",
"extended": {
"value": "красный",
"type": "string"
}
}
]
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
};

const response = await Users.updateUser(body);

Ví dụ với thuộc tính kiểu "entity" (danh sách lồng nhau)

const body = {
"formIdentifier": "reg",
"authData": [
{
"marker": "login",
"value": "test"
},
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "entity-selector",
"type": "entity",
"value": [
1,
2
]
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
};

const response = await Users.updateUser(body);

Ví dụ với thuộc tính kiểu "timeInterval"

const body = {
"formIdentifier": "reg",
"authData": [
{
"marker": "login",
"value": "test"
},
{
"marker": "password",
"value": "12345"
}
],
"formData": [
{
"marker": "interval",
"type": "timeInterval",
"value": [
[
"2025-02-11T16:00:00.000Z",
"2025-02-13T16:00:00.000Z"
]
]
}
],
"notificationData": {
"email": "test@test.ru",
"phonePush": [],
"phoneSMS": "+79991234567"
}
};

const response = await Users.updateUser(body);

Ví dụ trả về

true