Update Permissions class & docs

This commit is contained in:
venashial
2022-06-04 00:05:23 -07:00
parent 5b0aba99bb
commit 597c071c3d
2 changed files with 42 additions and 32 deletions

View File

@@ -58,16 +58,22 @@ The `markdownInline` parser is perfect for translations and short bios. It doesn
The `Permissions` class provides an easy way to manage user permissions.
```ts
```svelte example raised
<script lang="ts">
import { Permissions } from 'omorphia/utils'
const adminLevel = new Permissions('ALL')
const memberLevel = new Permissions(member.permissions) /* `member` from API */
const userLevel = new Permissions(0)
const permissions = new Permissions(128) // Can be integer or 'ALL'
</script>
if (memberLevel.data.uploadVersions) {
console.log('Can upload versions!')
}
<p>
<input type="checkbox" bind:checked={permissions.uploadVersions} id="ex-1"/>
<label for="ex-1">Can edit versions</label><br>
<input type="checkbox" bind:checked={permissions.deleteProject} id="ex-2"/>
<label for="ex-2">Can delete project</label><br><br>
Integer: {permissions.toInteger()}<br>
Can access settings page: {permissions.settingsPage}
</p>
```
## Versions