> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Security

> Security and access control in CRMScript.

Don't assume that a user has access to everything. It is good practice to look up access rights before revealing or altering information about a person or company.

The **activeuser** table holds info about currently signed-in users. Use it to look up who is signed in, at what location, and so on.

<Danger>
  Changing this table **might prevent users from signing in!** Fixing it requires intervention by SuperOffice support. Consider it a read-only table!
</Danger>

## Bool isLoggedIn(Integer origin)

Checks if the user is signed to the given endpoint.

* 1 = SOAP interface
* 2 = web pages

```crmscript theme={null}
User u;
u.load(2);
print(u.isLoggedIn(2).toString());
```

## Void login()

Creates a valid session for the current customer.

To get the session key created by `login()`, call `getValue("loginSessionKey")`.

```crmscript! theme={null}
Customer c;
c.load(7);
c.login();
printLine(c.getValue("loginSessionKey"));
c.logout();
```

## Void logout()

Logs out a customer.

## Bool isAdministrator()

Checks whether the user is an administrator.

## Bool checkTableRights(String tableRight)

`checkTableRights()` determines whether the current user has access to something.

Access pertains to one of the following tasks:

* select
* update
* insert

**Customer (person):**

```crmscript! theme={null}
Customer c;
c.load(5);

Bool b = c.checkTableRights("select");
printLine(b.toString());
```

**Company (contact):**

```crmscript! theme={null}
Company c;
c.load(2);

Bool b = c.checkTableRights("select");
printLine(b.toString());
```

## Bool checkFieldRights(String field, String fieldRight)

`checkFieldRights()` determines whether the current user has access to a field.

Access pertains to 1 of the following tasks:

* read
* write

**Customer (person):**

```crmscript theme={null}
Customer c;
c.load(5);

Bool b = c.checkFieldRights("person", "read");
print(b.toString());
```

**Company (contact):**

```crmscript theme={null}
Company c;
c.load(2);

Bool b = c.checkFieldRights("contact", "read");
print(b.toString());
```

## Bool hasTicketAccess(Integer ticketId, Integer accessLevel)

Checks whether the user meets the access level for a ticket.

| Access level | Ticket action |
| :----------: | ------------- |
|       0      | List          |
|       1      | Read          |
|       2      | Edit          |

```crmscript theme={null}
print(u.hasTicketAccess(42,1).toString());
```


## Related topics

- [Security](/en/automation/crmscript/security/index.md)
- [Security enhancements](/en/online/security.md)
- [Privacy and security](/integrations/supernotes/privacy-security.md)
- [Security and deployment](/en/onsite/security/index.md)
- [Security requirements](/en/developer-portal/standard-app/requirements/security.md)
- [Validating security tokens](/en/api/authentication/online/validate-security-tokens.md)
