Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add client support for handling disabled accounts #237

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading