✨ feat: add phone to instance creation
This commit is contained in:
@@ -4,6 +4,7 @@ import globalResolver from "../../../services/global-resolver";
|
|||||||
import User from "../../../services/user/entities/user";
|
import User from "../../../services/user/entities/user";
|
||||||
import yargs from "yargs";
|
import yargs from "yargs";
|
||||||
import { createCozyInstance } from "./utils";
|
import { createCozyInstance } from "./utils";
|
||||||
|
import { getLDAPUserMobile } from "./utils/ldap";
|
||||||
|
|
||||||
const migrateUsersCommand: yargs.CommandModule<unknown, unknown> = {
|
const migrateUsersCommand: yargs.CommandModule<unknown, unknown> = {
|
||||||
command: "migrate-users",
|
command: "migrate-users",
|
||||||
@@ -59,12 +60,14 @@ const migrateUsersCommand: yargs.CommandModule<unknown, unknown> = {
|
|||||||
|
|
||||||
for (const user of usersToMigrate) {
|
for (const user of usersToMigrate) {
|
||||||
const userId = user.email_canonical.split("@")[0];
|
const userId = user.email_canonical.split("@")[0];
|
||||||
|
const phone = await getLDAPUserMobile(userId);
|
||||||
const userObject = {
|
const userObject = {
|
||||||
_id: user.id,
|
_id: user.id,
|
||||||
id: userId,
|
id: userId,
|
||||||
email: user.email_canonical,
|
email: user.email_canonical,
|
||||||
name: `${user.first_name} ${user.last_name}`,
|
name: `${user.first_name} ${user.last_name}`,
|
||||||
locale: user.preferences?.locale || "fr",
|
locale: user.preferences?.locale || "fr",
|
||||||
|
phone
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!dryRun) {
|
if (!dryRun) {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export async function createCozyInstance(user: {
|
|||||||
name: string;
|
name: string;
|
||||||
_id: string;
|
_id: string;
|
||||||
locale: string;
|
locale: string;
|
||||||
|
phone: string;
|
||||||
}) {
|
}) {
|
||||||
console.log(`🚀 Creating Cozy instance for ${user.email}...`);
|
console.log(`🚀 Creating Cozy instance for ${user.email}...`);
|
||||||
|
|
||||||
@@ -54,6 +55,7 @@ export async function createCozyInstance(user: {
|
|||||||
public_name: user.name,
|
public_name: user.name,
|
||||||
locale: user.locale,
|
locale: user.locale,
|
||||||
oidc: user.id,
|
oidc: user.id,
|
||||||
|
phone: user.phone
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user