> For the complete documentation index, see [llms.txt](https://overleaf-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://overleaf-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 區段，然後點擊 (show) 連結。
* 勾選 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。
* 搜尋您要還原的使用者。
* 點擊 Display deleted 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://overleaf-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.
