mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 23:17:33 +00:00
rm unused code
This commit is contained in:
@@ -229,94 +229,3 @@ export class UserService {
|
|||||||
return this.grpcService.userNew.setPassword(create(SetPasswordRequestSchema, req));
|
return this.grpcService.userNew.setPassword(create(SetPasswordRequestSchema, req));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function userToV2(user: User): UserV2 {
|
|
||||||
const details = user.getDetails();
|
|
||||||
return create(UserSchema, {
|
|
||||||
userId: user.getId(),
|
|
||||||
details: details && detailsToV2(details),
|
|
||||||
state: user.getState() as number as UserState,
|
|
||||||
username: user.getUserName(),
|
|
||||||
loginNames: user.getLoginNamesList(),
|
|
||||||
preferredLoginName: user.getPreferredLoginName(),
|
|
||||||
type: typeToV2(user),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function detailsToV2(details: ObjectDetails): Details {
|
|
||||||
const changeDate = details.getChangeDate();
|
|
||||||
return create(DetailsSchema, {
|
|
||||||
sequence: BigInt(details.getSequence()),
|
|
||||||
changeDate: changeDate && timestampToV2(changeDate),
|
|
||||||
resourceOwner: details.getResourceOwner(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function timestampToV2(timestamp: Timestamp): TimestampV2 {
|
|
||||||
return create(TimestampSchema, {
|
|
||||||
seconds: BigInt(timestamp.getSeconds()),
|
|
||||||
nanos: timestamp.getNanos(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function typeToV2(user: User): UserV2['type'] {
|
|
||||||
const human = user.getHuman();
|
|
||||||
if (human) {
|
|
||||||
return { case: 'human', value: humanToV2(user, human) };
|
|
||||||
}
|
|
||||||
|
|
||||||
const machine = user.getMachine();
|
|
||||||
if (machine) {
|
|
||||||
return { case: 'machine', value: machineToV2(machine) };
|
|
||||||
}
|
|
||||||
|
|
||||||
return { case: undefined };
|
|
||||||
}
|
|
||||||
|
|
||||||
function humanToV2(user: User, human: Human): HumanUser {
|
|
||||||
const profile = human.getProfile();
|
|
||||||
const email = human.getEmail()?.getEmail();
|
|
||||||
const phone = human.getPhone();
|
|
||||||
const passwordChanged = human.getPasswordChanged();
|
|
||||||
|
|
||||||
return create(HumanUserSchema, {
|
|
||||||
userId: user.getId(),
|
|
||||||
state: user.getState() as number as UserState,
|
|
||||||
username: user.getUserName(),
|
|
||||||
loginNames: user.getLoginNamesList(),
|
|
||||||
preferredLoginName: user.getPreferredLoginName(),
|
|
||||||
profile: profile && humanProfileToV2(profile),
|
|
||||||
email: { email },
|
|
||||||
phone: phone && humanPhoneToV2(phone),
|
|
||||||
passwordChangeRequired: false,
|
|
||||||
passwordChanged: passwordChanged && timestampToV2(passwordChanged),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function humanProfileToV2(profile: Profile): HumanProfile {
|
|
||||||
return create(HumanProfileSchema, {
|
|
||||||
givenName: profile.getFirstName(),
|
|
||||||
familyName: profile.getLastName(),
|
|
||||||
nickName: profile.getNickName(),
|
|
||||||
displayName: profile.getDisplayName(),
|
|
||||||
preferredLanguage: profile.getPreferredLanguage(),
|
|
||||||
gender: profile.getGender() as number as Gender,
|
|
||||||
avatarUrl: profile.getAvatarUrl(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function humanPhoneToV2(phone: Phone): HumanPhone {
|
|
||||||
return create(HumanPhoneSchema, {
|
|
||||||
phone: phone.getPhone(),
|
|
||||||
isVerified: phone.getIsPhoneVerified(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function machineToV2(machine: Machine): MachineUser {
|
|
||||||
return create(MachineUserSchema, {
|
|
||||||
name: machine.getName(),
|
|
||||||
description: machine.getDescription(),
|
|
||||||
hasSecret: machine.getHasSecret(),
|
|
||||||
accessTokenType: machine.getAccessTokenType() as number as AccessTokenType,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user