> For the complete documentation index, see [llms.txt](https://ayakaleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ayakaleaf-pro.ayaka.space/on-premises/zh-tw/shi-yong-zhe-yu-zhuan-an-guan-li/user-management.md).

# 使用者管理

## 建立管理員使用者

Overleaf Toolkit 部署：

{% code title="Overleaf Toolkit" overflow="wrap" %}

```bash
$ bin/docker-compose exec sharelatex /bin/bash -ce "cd /overleaf/services/web && node modules/server-ce-scripts/scripts/create-user --admin --email=joe@example.com"
```

{% endcode %}

舊版 docker-compose.yml 部署：

{% code title="舊版 docker-compose" overflow="wrap" %}

```bash
$ docker exec sharelatex /bin/bash -ce "cd /overleaf/services/web && node modules/server-ce-scripts/scripts/create-user --admin --email=joe@example.com"
```

{% endcode %}

如果系統中尚未存在指定的電子郵件地址，這個命令會建立一個使用該電子郵件地址的使用者，並將其設為管理員。命令輸出會包含一個可前往的 URL，您可在那裡為此使用者設定密碼，並首次登入。

{% hint style="info" %}
若要以程式方式操作，您也可以使用相同的腳本來建立一般使用者與管理員。建立一般使用者時，請省略 --admin 參數。
{% endhint %}

如果您使用內部帳戶進行驗證，且需要將現有使用者提升為執行個體管理員或撤銷管理員權限，請執行以下操作：

{% stepper %}
{% step %}

### 透過管理員介面

* 以現有管理員身分登入。
* 點擊 Admin -> Manage Users。
* 搜尋該使用者，然後點擊其電子郵件地址。
* 向下捲動至 Site Admin 區段，然後點擊（顯示）連結。
* 勾選 Is Site Admin 核取方塊。
* 點擊 Save 完成。
  {% endstep %}
  {% endstepper %}

***

## 刪除使用者

如我們在關於 [了解授權使用情況](broken://pages/9628c0944f745d218c656f3235d4fa8791982b4d)的指南中所說明，一般建議不要刪除帳戶，除非它們已不再需要。刪除帳戶會移除該帳戶，並導致協作者無法存取專案。目前沒有停用帳戶的方法——它們不是保留資料而存在，就是被刪除。

預設情況下，帳戶會以軟刪除方式刪除。若要了解如何從您的執行個體中永久移除使用者，請參閱 `ENABLE_CRON_RESOURCE_DELETION` 在 [環境變數](broken://pages/bee4c82a30586f16dd4f9e8e432de3ea2df074eb) 指南。

{% hint style="info" %}
帳戶預設會以軟刪除方式刪除。請參閱 `ENABLE_CRON_RESOURCE_DELETION` 以了解永久刪除行為。
{% endhint %}

### 透過 Admin -> Manage Users

{% stepper %}
{% step %}

* 以管理員身分登入。
* 點擊 Admin -> Manage Users。
* 搜尋該使用者，並勾選其電子郵件地址旁的核取方塊。
* 點擊垃圾桶圖示。
* 點擊 Delete 以確認。
  {% endstep %}
  {% endstepper %}

### 透過命令列

可以使用以下命令刪除使用者帳戶（及其專案）。

Overleaf Toolkit 部署：

{% code title="Overleaf Toolkit" %}

```bash
$ bin/docker-compose exec sharelatex /bin/bash -ce "cd /overleaf/services/web && node modules/server-ce-scripts/scripts/delete-user.mjs --email=joe@example.com"
```

{% endcode %}

舊版 docker-compose.yml 部署：

{% code title="舊版 docker-compose" %}

```bash
$ docker exec sharelatex /bin/bash -ce "cd /overleaf/services/web && node modules/server-ce-scripts/scripts/delete-user.mjs --email=joe@example.com"
```

{% endcode %}

{% hint style="danger" %}
刪除腳本使用了硬式編碼的 force 選項，即使帳戶刪除電子郵件傳送失敗，也能確保刪除流程繼續進行（例如，使用者的電子郵件已不再服務時）。
{% endhint %}

{% hint style="info" %}
自 5.5.0 版起，可使用 --skip-email 選項以避免向已刪除的使用者傳送通知電子郵件。
{% endhint %}

***

## 還原軟刪除的使用者

如果使用者只是被軟刪除，您可以還原其帳戶與專案。

{% stepper %}
{% step %}

* 以管理員身分登入。
* 點擊 Admin -> Manage Users。
* 搜尋您要還原的使用者。
* 點擊顯示已刪除使用者按鈕。
* 點擊已刪除使用者的電子郵件地址。
* 點擊 Recover This Account。
* 點擊 Recover 以確認。
  {% endstep %}
  {% endstepper %}

{% hint style="danger" %}
當 ENABLE\_CRON\_RESOURCE\_DELETION 設為 true 時，軟刪除的帳戶可在 90 天內還原。90 天後，便無法恢復帳戶。
{% endhint %}

***

## 計算使用者數量

您可以透過 <https://you-instance-url/admin/user#license> 的管理員介面取得使用者數量。若要進行程式化檢查與匯出，以下範例或許有所幫助。

使用者總數：

{% code title="使用者總數" %}

```bash
echo 'db.users.countDocuments()' | docker exec -i mongo mongosh --quiet localhost/sharelatex
# overleaf [direct: primary] sharelatex> 16
```

{% endcode %}

透過 metrics 端點取得的使用者總數：

{% code title="metrics 中的活躍使用者數" %}

```bash
docker exec sharelatex curl http://127.0.0.1:3000/metrics | grep num_active_users
# # HELP num_active_users num_active_users
# # TYPE num_active_users gauge
# num_active_users{app="web-api",host="b3ae4ff549d8"} 16
```

{% endcode %}

活躍使用者總數（例如：過去 365 天內有活動的使用者）：

{% code title="活躍使用者總數" %}

```bash
echo 'db.users.countDocuments({ lastActive: { $gte: new Date(new Date().getTime() - (365 * 24 * 60 * 60 * 1000)) } })' | docker exec -i mongo mongosh --quiet localhost/sharelatex
# overleaf [direct: primary] sharelatex> 10
```

{% endcode %}

***

## 更新使用者帳戶資訊

帳戶更新的方式取決於是否啟用 SSO。

* 如果未使用 SSO：
  * 管理員可以透過 Admin -> Manage Users 修改使用者帳戶資訊（電子郵件、名字、姓氏，以及產生密碼重設連結）。
  * 一般使用者可以透過 Account -> Account Settings 更新自己的資料（包括變更密碼與產生 Git 驗證權杖）。
* 如果使用 SSO：
  * 可將 Server Pro 設定為根據驗證系統，在登入時更新使用者的名字與姓氏。
  * 當 OVERLEAF\_SAML\_UPDATE\_USER\_DETAILS\_ON\_LOGIN 或 OVERLEAF\_LDAP\_UPDATE\_USER\_DETAILS\_ON\_LOGIN 為 true 時，<https://your-instance-url/user/settings> 上的使用者詳細資料表單會被停用，名字／姓氏只能在您的身分管理系統中設定。

更多詳細資訊請參閱：

* SAML 2.0 設定：<https://docs.overleaf.com/on-premises/configuration/overleaf-toolkit/server-pro-only-configuration/saml-2.0>
* LDAP 設定：<https://docs.overleaf.com/on-premises/configuration/overleaf-toolkit/server-pro-only-configuration/ldap>

***

最後更新於 4 個月前

此說明文件頁面包含外部指南與設定頁面的連結。所有連結與查詢參數均如原始內容中所保留。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ayakaleaf-pro.ayaka.space/on-premises/zh-tw/shi-yong-zhe-yu-zhuan-an-guan-li/user-management.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
