Skip to content

Commit

Permalink
Adds basic permissions system in users and groups
Browse files Browse the repository at this point in the history
  • Loading branch information
ap0k4 committed Feb 9, 2024
1 parent 9a49745 commit 0ff8a23
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/protolib/bundles/groups/groupsSchemas.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { z } from "protolib/base";
import { Schema } from 'protolib/base'
import moment from "moment";
import { AutoModel } from 'protolib/base'

export const GroupSchema = Schema.object({
name: z.string().label('name').hint('user, admin, ...').static().id().search(),
workspaces: z.array(z.string()).hidden(),
permissions: z.array(z.string()).optional(),
admin: z.boolean().optional()
})

Expand Down
3 changes: 2 additions & 1 deletion packages/protolib/bundles/users/usersSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { AutoModel } from 'protolib/base'

export const UserSchema = Schema.object({
username: z.string().email().label('email').hint('user@example.com').static().id().search(),
type: z.string().min(1).hint('user, admin, ...').search().help("The type refers to a group name. Groups contains privileges (admin true/false) and workspaces."),
type: z.string().min(1).label("group").hint('user, admin, ...').search().help("The type refers to a group name. Groups contains privileges (admin true/false) and workspaces."),
password: z.string().min(6).hint('**********').secret().onCreate('cypher').onUpdate('update').onRead('clearPassword').onList('clearPassword').help("Salted hashed password using bcrypt."),
permissions: z.array(z.string()).optional().label("additional permissions"),
createdAt: z.string().min(1).generate((obj) => moment().toISOString()).search().hidden(),
lastLogin: z.string().optional().search().hidden(),
from: z.string().min(1).search().generate((obj) => 'admin').help("Interface used to create the user. Users can be created from command line or from the admin panel").hidden()
Expand Down

0 comments on commit 0ff8a23

Please sign in to comment.