> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 用户名迁移

## 用户名迁移

从登录的角度来看，用户的主要标识符是其邮箱地址。如果你正在从本地认证迁移到 SSO，或者从一个 IdP 迁移到另一个 IdP，你可能需要更新用户的邮箱地址。

为此，我们提供了一个脚本，可以使用以下格式的 CSV 文件迁移用户邮箱：

`oldEmail,newEmail`

在执行一些验证检查后，该脚本会遍历 CSV 文件，将用户的邮箱地址从 `oldEmail` 更新为 `newEmail`。

### **验证**

在运行迁移之前，会检查 `<csv_file>` 以确保：

* 每一行中的 `oldEmail` 和 `newEmail` 都是有效的邮箱地址
* 没有重复条目，例如，你没有尝试将不同的用户更新为同一个新邮箱地址，也没有尝试用一个已被使用的邮箱地址更新同一个用户账户

### **用法**

```bash wrap theme={null}
docker cp <csv_file> sharelatex:/overleaf/services/web/<csv_file> docker exec sharelatex /bin/bash -c "cd /overleaf/services/web;node ./modules/server-ce-scripts/scripts/migrate-user-emails.js [--commit] [--continue|--ignore-missing] [--admin-id=ADMIN_USER_ID] <csv_file>"
```

### **标志**

| 名称 | 描述 |
| - | - |
| `--commit` | <p>加入 `--commit` 标志后才会真正执行迁移。如果省略该标志，迁移将以试运行模式进行，不会做出任何更改，但仍会执行验证。<br /><br /><strong>默认值</strong>：`false`</p> |
| `--continue` | 如果某个用户账户的邮箱地址已经被更新，`--continue` 标志会让迁移过程继续进行 |
| `--ignore-missing` | 如果未找到某个用户账户，`--ignore-missing` 标志会让迁移过程继续进行 |
| `--admin-id` | `--admin-id` 应设置为执行迁移的管理员的 ID，并将用于审计日志条目。前往 **Admin** > **Manage Users**，搜索你的邮箱地址并点击第一个结果，即可找到你的用户 ID。 |
| `<csv_file>` | `<csv_file>` 是包含新旧邮箱地址的文件 |

### **完成**

在执行迁移脚本时，你所选择的标志将决定错误在记录到控制台后是继续执行还是退出。如果脚本因错误而提前终止，它将以退出码 1 退出，表示执行不成功。

迁移完成后，脚本会在控制台中记录成功、失败和跳过的更新数量。如果迁移成功完成，它将以退出码 0 退出。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.