Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!auth) {
throw Error(
`You must register a "security-authentication-provider" plugin to render Account form!`
);
}
const { renderUserAccountForm } = auth;
const [{ loading, user }, setState] = useReducer((prev, next) => ({ ...prev, ...next }), {
loading: true,
user: { data: {} }
});
const client = useApolloClient();
const { showSnackbar } = useSnackbar();
const security = useSecurity();
const onSubmit = useHandler(null, () => async formData => {
setState({ loading: true });
const { data: response } = await client.mutate({
mutation: UPDATE_CURRENT_USER,
variables: { data: omit(formData, ["id"]) }
});
const { error } = response.security.updateCurrentUser;
setState({ loading: false });
if (error) {
return showSnackbar(error.message, {
actionText: "Close"
});
}
security.refreshUser();
show: () => hasRoles(roles),
type: "integration",
export default ({ children, scopes, roles }: Object): React.Node => {
const checks = {
scopes: scopes ? hasScopes(scopes) : true,
roles: roles ? hasRoles(roles) : true
};
if (typeof children === "function") {
return children(checks);
}
return checks.scopes && checks.roles ? children : null;
};
const UserInfo = () => {
const security = useSecurity();
if (!security || !security.user) {
return null;
}
const { email, fullName, avatar } = security.user;
return (
export default ({ children, scopes, roles }: Object): React.Node => {
const checks = {
scopes: scopes ? hasScopes(scopes) : true,
roles: roles ? hasRoles(roles) : true
};
if (typeof children === "function") {
return children(checks);
}
return checks.scopes && checks.roles ? children : null;
};
>
)}
))}
)}
);
};
export default compose(
withSecurity(),
withRouter
)(UsersDataList);