# 用户-Old

## 登录

## 登录CRAFT

<mark style="color:green;">`POST`</mark> `https://bbs.arktoolbox.jamsg.cn/api/token`

登录

#### Request Body

| Name                                             | Type   | Description |
| ------------------------------------------------ | ------ | ----------- |
| identification<mark style="color:red;">\*</mark> | string | 用户名/电子邮箱    |
| password<mark style="color:red;">\*</mark>       | string | 密码          |

{% tabs %}
{% tab title="200: OK 登录成功" %}

```javascript
{
    "token": "访问令牌",
    "userId": 用户ID
}
```

{% endtab %}

{% tab title="401: Unauthorized 登录失败" %}

```javascript
{
    "errors": [
        {
            "status": "401",
            "code": "not_authenticated"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**提示:** 这个API需要使用JSON方式POST
{% endhint %}

## 注册

## 创建CRAFT新用户

<mark style="color:green;">`POST`</mark> `https://bbs.arktoolbox.jamsg.cn/api/users`

创建新用户

#### Headers

| Name                                            | Type   | Description |
| ----------------------------------------------- | ------ | ----------- |
| Authorization<mark style="color:red;">\*</mark> | string | 最高权限Token   |

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| username<mark style="color:red;">\*</mark> | string | 用户名         |
| email<mark style="color:red;">\*</mark>    | string | 电子邮箱        |
| password<mark style="color:red;">\*</mark> | string | 密码          |

{% tabs %}
{% tab title="201: Created 注册成功" %}

```javascript
{
    "data": {
        "type": "users",
        "id": "38893",
        "attributes": {
            "username": "JamXi-Test2",
            "displayName": "JamXi-Test2",
            "avatarUrl": null,
            "slug": "38893",
            "joinTime": "2022-08-16T13:38:32+00:00",
            "discussionCount": 0,
            "commentCount": 0,
            "canEdit": true,
            "canEditCredentials": true,
            "canEditGroups": true,
            "canDelete": true,
            "lastSeenAt": null,
            "isEmailConfirmed": true,
            "email": "jamxitest2@jamsg.cn",
            "markedAllAsReadAt": null,
            "unreadNotificationCount": 0,
            "newNotificationCount": 0,
            "preferences": {
                "fofNightMode": null,
                "fofNightMode_perDevice": false,
                "followAfterReply": false,
                "localDiscussionsOnly": null,
                "discussionOpenLastRead": null,
                "notify_discussionRenamed_alert": true,
                "notify_userSuspended_alert": true,
                "notify_userSuspended_email": true,
                "notify_userUnsuspended_alert": true,
                "notify_userUnsuspended_email": true,
                "notify_postLiked_alert": true,
                "notify_selectBestAnswer_alert": true,
                "notify_selectBestAnswer_email": true,
                "notify_awardedBestAnswer_alert": true,
                "notify_awardedBestAnswer_email": false,
                "notify_bestAnswerInDiscussion_alert": false,
                "notify_bestAnswerInDiscussion_email": false,
                "notify_newPost_alert": true,
                "notify_newPost_email": true,
                "notify_postMentioned_alert": true,
                "notify_postMentioned_email": false,
                "notify_userMentioned_alert": true,
                "notify_userMentioned_email": false,
                "notify_discussionLocked_alert": true,
                "notify_warning_alert": true,
                "notify_warning_email": true,
                "discloseOnline": true,
                "indexProfile": true,
                "locale": null
            },
            "isAdmin": false,
            "canEditNickname": true,
            "suspendReason": null,
            "suspendMessage": null,
            "suspendedUntil": null,
            "canSuspend": true,
            "canFoFImpersonate": true,
            "impersonateReasonRequired": false,
            "usernameHistory": null,
            "bio": null,
            "canViewBio": true,
            "canEditBio": true,
            "fof-upload-uploadCountCurrent": 0,
            "fof-upload-uploadCountAll": 0,
            "canSpamblock": true,
            "canViewSocialProfile": true,
            "socialButtons": null,
            "canEditSocialProfile": true,
            "canEditPolls": true,
            "canStartPolls": true,
            "canSelfEditPolls": true,
            "canVotePolls": true,
            "moderatorNoteCount": 0,
            "bestAnswerCount": 0,
            "isBanned": false,
            "canBanIP": true,
            "canEditOwnLocation": false,
            "locationInfo": null,
            "disclosePostedOn": false,
            "likesReceived": 0,
            "canViewWarnings": false,
            "canManageWarnings": false,
            "canDeleteWarnings": false,
            "visibleWarningCount": 0,
            "newFlagCount": 0,
            "fof-upload-viewOthersMediaLibrary": true,
            "fof-upload-deleteOthersMediaLibrary": true,
            "canViewModeratorNotes": true,
            "canCreateModeratorNotes": true,
            "canDeleteModeratorNotes": true
        },
        "relationships": {
            "banned_ips": {
                "data": []
            }
        }
    }
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity 注册失败" %}

```javascript
{
    "errors": [
        {
            "status": "422",
            "code": "validation_error",
            "detail": "username 已被采用。",
            "source": {
                "pointer": "/data/attributes/username"
            }
        },
        {
            "status": "422",
            "code": "validation_error",
            "detail": "email 已被采用。",
            "source": {
                "pointer": "/data/attributes/email"
            }
        }
    ]
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**提示:** 这个API需要使用JSON方式POST

最高权限Token请询问**JamXi**
{% endhint %}

## 读取用户信息

## 读取CRAFT用户信息

<mark style="color:blue;">`GET`</mark> `https://bbs.arktoolbox.jamsg.cn/api/users/<userid>`

**公开API**

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | String |             |

{% tabs %}
{% tab title="200: OK 回传用户信息" %}

```javascript
{
    "data": {
        "type": "users",
        "id": "用户序号",
        "attributes": {
            "username": "用户名",
            "displayName": "昵称",
            "avatarUrl": 头像链接(仅包含文件名),
            "slug": "网址slug",
            "joinTime": "加入时间",
            "discussionCount": 发帖数量,
            "commentCount": 评论数量,
            "canEdit": 是否可以编辑(Token权限),
            "canEditGroups": 是否可以编辑组位置(Token权限),
            "canDelete": 是否可以删除(Token权限),
            "lastSeenAt": 上次登陆时间,
            "isEmailConfirmed": 电子邮件是否已经验证(默认是),
            "email": "电子邮件",
            "markedAllAsReadAt": 上次一键已读时间,
            "unreadNotificationCount": 未读通知数量,
            "newNotificationCount": 新通知数量,
            "preferences": {
                "showSynopsisExcerpts": 在全部主题列表中显示每个主题帖的摘要（电脑/平板端）,
                "showSynopsisExcerptsOnMobile": 在全部主题列表中显示每个主题帖的摘要（手机端）,
                "fofNightMode": 日夜模式,
                "fofNightMode_perDevice": 独立设备配置,
                "followAfterReply": 自动关注我回复的主题,
                "discussionOpenLastRead": 进入帖子时自动转到最新的评论,
                "notify_discussionRenamed_alert": true,
                "notify_userSuspended_alert": true,
                "notify_userSuspended_email": true,
                "notify_userUnsuspended_alert": true,
                "notify_userUnsuspended_email": true,
                "notify_postLiked_alert": true,
                "notify_selectBestAnswer_alert": true,
                "notify_selectBestAnswer_email": true,
                "notify_awardedBestAnswer_alert": true,
                "notify_awardedBestAnswer_email": false,
                "notify_bestAnswerInDiscussion_alert": false,
                "notify_bestAnswerInDiscussion_email": false,
                "notify_newPost_alert": true,
                "notify_newPost_email": true,
                "notify_postMentioned_alert": true,
                "notify_postMentioned_email": false,
                "notify_userMentioned_alert": true,
                "notify_userMentioned_email": false,
                "notify_discussionLocked_alert": true,
                "notify_warning_alert": true,
                "notify_warning_email": true,
                "discloseOnline": true,
                "indexProfile": true,
                "locale": null
            },
            "isAdmin": 是否管理员,
            "canEditNickname": 是否可以编辑昵称,
            "suspendReason": 封禁原因,
            "suspendMessage": 封禁消息,
            "suspendedUntil": 封禁到什么时候,
            "canSuspend": 是否可被封禁,
            "impersonateReasonRequired": false,
            "usernameHistory": 签名历史记录,
            "bio": 签名,
            "canViewBio": 是否可查看签名,
            "canEditBio": 是否可编辑签名,
            "fof-upload-uploadCountCurrent": 文件上传数量,
            "fof-upload-uploadCountAll": 所有文件上传数量,
            "canSpamblock": 是否发垃圾消息封禁,
            "canViewSocialProfile": 是否可查看社交账号,
            "socialButtons": 社交账号,
            "canEditSocialProfile": 是否可编辑社交账号,
            "canEditPolls": 是否可编辑投票,
            "canStartPolls": 是否可开始投票,
            "canSelfEditPolls": 是否自己可以编辑投票,
            "canVotePolls": 是否可以进行投票,
            "moderatorNoteCount": 站务警告次数,
            "bestAnswerCount": 最佳答案数量,
            "isBanned": 是否被BAN,
            "canBanIP": 是否可以封禁IP,
            "disclosePostedOn": false,
            "likesReceived": 收到的赞,
            "canViewWarnings": 是否可以查看警告,
            "canManageWarnings": 是否可以管理警告,
            "canDeleteWarnings": 是否可以删除警告,
            "visibleWarningCount": 可见的警告次数,
            "newFlagCount": 举报次数,
            "fof-upload-viewOthersMediaLibrary": 是否可以查看所有上传的媒体,
            "fof-upload-deleteOthersMediaLibrary": 是否可以删除所有上传的媒体,
            "canViewModeratorNotes": 是否可以查看站务警告,
            "canCreateModeratorNotes": 是否可以创建站务警告,
            "canDeleteModeratorNotes": 是否可以删除站务警告
        },
        "relationships": {
            "banned_ips": {
                "data": []
            }
        }
    }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Good to know:** This API method was auto-generated from an example Swagger file. You'll see that it's not editable – that's because the contents are synced to an URL! Any time the linked file changes, the documentation will change too.
{% endhint %}
