Skip to content

Commit

Permalink
feat: add client support for handling disabled accounts (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-aleksander authored Jun 12, 2024
1 parent 07735f2 commit fa7d3b2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const AddInstanceInitForm = ({ nextStep }: Props) => {
}
// register new instance
// is user in need of full enrollment ?
if (r.user.is_active) {
if (r.user.enrolled) {
//no, only create new device for desktop client
debug('User already active, adding device only.');
nextStep({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,31 @@ export const DesktopSetup = () => {
const deviceResponse = await createDeviceMutation({
name: values.name,
pubkey: publicKey,
}).then((res) => {
if (!res.ok) {
toaster.error(LL.common.messages.error());
error(
`Failed to create device during the enrollment. Error details: ${JSON.stringify(
res.data,
)} Error status code: ${JSON.stringify(res.status)}`,
);
throw Error('Failed to create device');
}
return res;
});
mutateUserActivation({
password: userPassword,
phone_number: userInfo.phone_number,
}).then(() => {
}).then((res) => {
if (!res.ok) {
toaster.error(LL.common.messages.error());
error(
`Failed to activate user during the enrollment. Error details: ${JSON.stringify(
res.data,
)} Error status code: ${JSON.stringify(res.status)}`,
);
throw Error('Failed to activate user');
}
info('User activated');
setIsLoading(true);
debug('Invoking save_device_config');
Expand Down
2 changes: 2 additions & 0 deletions src/shared/hooks/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type UserInfo = {
is_active: boolean;
phone_number: string;
device_names: string[];
enrolled: boolean;
};

export type EnrollmentStartRequest = {
Expand Down Expand Up @@ -83,6 +84,7 @@ export type EnrollmentInitialUserInfo = {
email: string;
phone_number?: string;
is_active: boolean;
enrolled: boolean;
};

export type EnrollmentInstanceInfo = {
Expand Down

0 comments on commit fa7d3b2

Please sign in to comment.