How to use @webiny/app-security - 6 common examples

To help you get started, we’ve selected a few @webiny/app-security examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages / app-security / src / admin / views / Account.js View on Github external
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();
github webiny / webiny-js / packages / app-security / src / components / SecureView.js View on Github external
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;
};
github webiny / webiny-js / packages / app-security / src / admin / plugins / UserMenu / UserInfo.js View on Github external
const UserInfo = () => {
    const security = useSecurity();

    if (!security || !security.user) {
        return null;
    }

    const { email, fullName, avatar } = security.user;

    return (
github webiny / webiny-js / packages / app-security / src / components / SecureView.js View on Github external
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;
};
github webiny / webiny-js / packages / app-security / src / admin / views / Users / UsersDataList.js View on Github external
>
                                            
                                        
                                    )}
                                
                            
                        
                    ))}
                
            )}
        
    );
};

export default compose(
    withSecurity(),
    withRouter
)(UsersDataList);

@webiny/app-security

[![](https://img.shields.io/npm/dw/@webiny/app-security.svg)](https://www.npmjs.com/package/@webiny/app-security) [![](https://img.shields.io/npm/v/@webiny/app-security.svg)](https://www.npmjs.com/package/@webiny/app-security) [![code style: prettier](ht

MIT
Latest version published 19 days ago

Package Health Score

80 / 100
Full package analysis

Similar packages