mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-02-14 23:48:30 -06:00
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package user
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/shroff/phylum/server/internal/core/db"
|
|
"github.com/shroff/phylum/server/internal/core/fs"
|
|
)
|
|
|
|
type User struct {
|
|
Username string `json:"username"`
|
|
DisplayName string `json:"display"`
|
|
Permissions int32 `json:"-"`
|
|
Root uuid.UUID `json:"-"`
|
|
Home uuid.UUID `json:"-"`
|
|
}
|
|
|
|
func (u User) OpenFileSystem(ctx context.Context) fs.FileSystem {
|
|
return fs.Open(ctx, u.Username, u.Root, u.Permissions&PermissionAllFiles != 0)
|
|
}
|
|
|
|
type Manager interface {
|
|
// manager.go
|
|
WithDb(db *db.DbHandler) Manager
|
|
|
|
// create.go
|
|
CreateUser(username, displayName, password string, root uuid.UUID) (User, error)
|
|
|
|
// select.go
|
|
ListUsers(since *time.Time) ([]User, error)
|
|
UserByEmail(email string) (User, error)
|
|
|
|
// update.go
|
|
UpdateUserRoot(user User, root uuid.UUID) error
|
|
UpdateUserHome(user User, home uuid.UUID) error
|
|
UpdateUserDisplayName(user User, displayName string) error
|
|
|
|
// auth.go
|
|
VerifyUserPassword(email, password string) (User, error)
|
|
CreateAccessToken(username string) (string, error)
|
|
ReadAccessToken(accessToken string) (User, error)
|
|
|
|
// bookmarks.go
|
|
AddBookmark(u User, resource fs.Resource, name string) (Bookmark, error)
|
|
RemoveBookmark(u User, id uuid.UUID) (Bookmark, error)
|
|
ListBookmarks(u User, since *time.Time) ([]Bookmark, error)
|
|
|
|
// shared.go
|
|
SharedResources(u User) (result []fs.ResourceInfo, err error)
|
|
}
|