feat: dashboard - add actions to update is_multi_factor_auth_enabled
This commit is contained in:
parent
ef22318d5c
commit
9fae8215d2
|
@ -108,7 +108,7 @@ const OAuthConfig = ({
|
|||
fieldVisibility={fieldVisibility}
|
||||
setFieldVisibility={setFieldVisibility}
|
||||
inputType={HiddenInputType.GOOGLE_CLIENT_SECRET}
|
||||
placeholder="Google Secret"
|
||||
placeholder="Google Client Secret"
|
||||
/>
|
||||
</Center>
|
||||
</Flex>
|
||||
|
@ -146,7 +146,7 @@ const OAuthConfig = ({
|
|||
fieldVisibility={fieldVisibility}
|
||||
setFieldVisibility={setFieldVisibility}
|
||||
inputType={HiddenInputType.GITHUB_CLIENT_SECRET}
|
||||
placeholder="Github Secret"
|
||||
placeholder="Github Client Secret"
|
||||
/>
|
||||
</Center>
|
||||
</Flex>
|
||||
|
@ -184,7 +184,7 @@ const OAuthConfig = ({
|
|||
fieldVisibility={fieldVisibility}
|
||||
setFieldVisibility={setFieldVisibility}
|
||||
inputType={HiddenInputType.FACEBOOK_CLIENT_SECRET}
|
||||
placeholder="Facebook Secret"
|
||||
placeholder="Facebook Client Secret"
|
||||
/>
|
||||
</Center>
|
||||
</Flex>
|
||||
|
@ -260,7 +260,7 @@ const OAuthConfig = ({
|
|||
fieldVisibility={fieldVisibility}
|
||||
setFieldVisibility={setFieldVisibility}
|
||||
inputType={HiddenInputType.APPLE_CLIENT_SECRET}
|
||||
placeholder="Apple CLient Secret"
|
||||
placeholder="Apple Client Secret"
|
||||
/>
|
||||
</Center>
|
||||
</Flex>
|
||||
|
|
|
@ -89,6 +89,7 @@ export const UserDetailsQuery = `
|
|||
roles
|
||||
created_at
|
||||
revoked_timestamp
|
||||
is_multi_factor_auth_enabled
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ interface userDataTypes {
|
|||
roles: [string];
|
||||
created_at: number;
|
||||
revoked_timestamp: number;
|
||||
is_multi_factor_auth_enabled?: boolean;
|
||||
}
|
||||
|
||||
const enum updateAccessActions {
|
||||
|
@ -250,6 +251,34 @@ export default function Users() {
|
|||
break;
|
||||
}
|
||||
};
|
||||
const multiFactorAuthUpdateHandler = async (user: userDataTypes) => {
|
||||
const res = await client
|
||||
.mutation(UpdateUser, {
|
||||
params: {
|
||||
id: user.id,
|
||||
is_multi_factor_auth_enabled: !user.is_multi_factor_auth_enabled,
|
||||
},
|
||||
})
|
||||
.toPromise();
|
||||
if (res.data?._update_user?.id) {
|
||||
toast({
|
||||
title: `Multi factor authentication ${
|
||||
user.is_multi_factor_auth_enabled ? 'disabled' : 'enabled'
|
||||
} for user`,
|
||||
isClosable: true,
|
||||
status: 'success',
|
||||
position: 'bottom-right',
|
||||
});
|
||||
updateUserList();
|
||||
return;
|
||||
}
|
||||
toast({
|
||||
title: 'Multi factor authentication update failed for user',
|
||||
isClosable: true,
|
||||
status: 'error',
|
||||
position: 'bottom-right',
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Box m="5" py="5" px="10" bg="white" rounded="md">
|
||||
|
@ -273,6 +302,7 @@ export default function Users() {
|
|||
<Th>Roles</Th>
|
||||
<Th>Verified</Th>
|
||||
<Th>Access</Th>
|
||||
<Th>MFA</Th>
|
||||
<Th>Actions</Th>
|
||||
</Tr>
|
||||
</Thead>
|
||||
|
@ -305,6 +335,19 @@ export default function Users() {
|
|||
{user.revoked_timestamp ? 'Revoked' : 'Enabled'}
|
||||
</Tag>
|
||||
</Td>
|
||||
<Td>
|
||||
<Tag
|
||||
size="sm"
|
||||
variant="outline"
|
||||
colorScheme={
|
||||
user.is_multi_factor_auth_enabled ? 'green' : 'red'
|
||||
}
|
||||
>
|
||||
{user.is_multi_factor_auth_enabled
|
||||
? 'Enabled'
|
||||
: 'Disabled'}
|
||||
</Tag>
|
||||
</Td>
|
||||
<Td>
|
||||
<Menu>
|
||||
<MenuButton as={Button} variant="unstyled" size="sm">
|
||||
|
@ -357,6 +400,19 @@ export default function Users() {
|
|||
Revoke Access
|
||||
</MenuItem>
|
||||
)}
|
||||
{user.is_multi_factor_auth_enabled ? (
|
||||
<MenuItem
|
||||
onClick={() => multiFactorAuthUpdateHandler(user)}
|
||||
>
|
||||
Disable MFA
|
||||
</MenuItem>
|
||||
) : (
|
||||
<MenuItem
|
||||
onClick={() => multiFactorAuthUpdateHandler(user)}
|
||||
>
|
||||
Enable MFA
|
||||
</MenuItem>
|
||||
)}
|
||||
</MenuList>
|
||||
</Menu>
|
||||
</Td>
|
||||
|
|
|
@ -46,7 +46,7 @@ func UpdateProfileResolver(ctx context.Context, params model.UpdateProfileInput)
|
|||
}
|
||||
|
||||
// validate if all params are not empty
|
||||
if params.GivenName == nil && params.FamilyName == nil && params.Picture == nil && params.MiddleName == nil && params.Nickname == nil && params.OldPassword == nil && params.Email == nil && params.Birthdate == nil && params.Gender == nil && params.PhoneNumber == nil && params.NewPassword == nil && params.ConfirmNewPassword == nil {
|
||||
if params.GivenName == nil && params.FamilyName == nil && params.Picture == nil && params.MiddleName == nil && params.Nickname == nil && params.OldPassword == nil && params.Email == nil && params.Birthdate == nil && params.Gender == nil && params.PhoneNumber == nil && params.NewPassword == nil && params.ConfirmNewPassword == nil && params.IsMultiFactorAuthEnabled == nil {
|
||||
log.Debug("All params are empty")
|
||||
return res, fmt.Errorf("please enter at least one param to update")
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ func UpdateUserResolver(ctx context.Context, params model.UpdateUserInput) (*mod
|
|||
"user_id": params.ID,
|
||||
})
|
||||
|
||||
if params.GivenName == nil && params.FamilyName == nil && params.Picture == nil && params.MiddleName == nil && params.Nickname == nil && params.Email == nil && params.Birthdate == nil && params.Gender == nil && params.PhoneNumber == nil && params.Roles == nil {
|
||||
if params.GivenName == nil && params.FamilyName == nil && params.Picture == nil && params.MiddleName == nil && params.Nickname == nil && params.Email == nil && params.Birthdate == nil && params.Gender == nil && params.PhoneNumber == nil && params.Roles == nil && params.IsMultiFactorAuthEnabled == nil {
|
||||
log.Debug("No params to update")
|
||||
return res, fmt.Errorf("please enter atleast one param to update")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user