Developer Docs

Using Global store security in C#Bot client-side

The client-side of an application is not a reliable place to verify security, this is instead the duty of the server-side which considers user authentication, CRUD permissions and other considerations. However, it is important for the client-side to reflect the security rules. While the Codebots Security Diagram will have pre-configured security for you in both the client and server-side, it is important for you to understand client-side security to work with your custom code.

Using Global Store Security

Store.tsx is a global store which is used throughout your application. This store contains useful helper methods and information relating to the current user. This includes but is not limited to the following:

With how the store is setup, you can access any of this information in your components by first importing the store

import { store } from './Models/Store';

and then calling any methods of class variables. As an example, if you wanted to list out all the groups the user has access to you could call the following code snippet inside your component.

{store.userGroups.map(g => <p>{g.name}</p>)}

You can use any combination of these class variables or methods in your components logic to render a view suitable to your type of user.

if(store.loggedIn && store.hasBackendAccess) {
    return <p>Welcome Administrator!</p>;
    } else {
    return (
        <p>
            You are not logged, please click <Link to="/login">here</Link>
        </p>
    );
    }

Was this article helpful?

Thanks for your feedback!

If you would like to tell us more, please click on the link below to send us a message with more details.

Tool:

Generate

Iterate

Bot:

C#Bot

SpringBot

On this page

New to Codebots?

We know our software can be complicated, so we are always happy to have a chat if you have any questions.