1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-11-24 08:22:29 +02:00

Linux app: set single-user token

This commit is contained in:
Chen-I Lim 2021-02-09 15:46:49 -08:00
parent 93b9eac852
commit 89b8c0a18d
4 changed files with 43 additions and 22 deletions

48
.vscode/launch.json vendored
View File

@ -11,28 +11,36 @@
"mode": "debug",
"program": "${workspaceFolder}/server/main",
"cwd": "${workspaceFolder}"
},
{
"name": "Go: Launch Windows App",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/win",
"cwd": "${workspaceFolder}/win/temp",
},
{
"name": "Go: Test Current File",
},
{
"name": "Go: Launch Windows App",
"type": "go",
"request": "launch",
"mode": "test",
"remotePath": "",
"port": 8888,
"host": "127.0.0.1",
"program": "${file}",
"env": {},
"args": [],
"showLog": true
},
"mode": "debug",
"program": "${workspaceFolder}/win",
"cwd": "${workspaceFolder}/win/temp",
},
{
"name": "Go: Launch Linux App",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/linux",
"cwd": "${workspaceFolder}/linux/dist/focalboard-app",
},
{
"name": "Go: Test Current File",
"type": "go",
"request": "launch",
"mode": "test",
"remotePath": "",
"port": 8888,
"host": "127.0.0.1",
"program": "${file}",
"env": {},
"args": [],
"showLog": true
},
{
"name": "Attach by Process ID",
"processId": "${command:PickProcess}",

View File

@ -2,4 +2,7 @@ module github.com/mattermost/focalboard/linux
go 1.15
require github.com/webview/webview v0.0.0-20200724072439-e0c01595b361
require (
github.com/google/uuid v1.2.0
github.com/webview/webview v0.0.0-20200724072439-e0c01595b361
)

View File

@ -1,2 +1,4 @@
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/webview/webview v0.0.0-20200724072439-e0c01595b361 h1:e0+/fQY5l9NdCwPsEg9S8AgE5lFhZ/6UX+b2KkpIBFg=
github.com/webview/webview v0.0.0-20200724072439-e0c01595b361/go.mod h1:rpXAuuHgyEJb6kXcXldlkOjU6y4x+YcASKKXJNUhh0Y=

View File

@ -2,16 +2,20 @@ package main
import (
"context"
"fmt"
"log"
"os"
"os/exec"
"strconv"
"github.com/google/uuid"
"github.com/webview/webview"
)
var sessionToken string = "su-" + uuid.New().String()
func runServer(ctx context.Context) {
cmd := exec.CommandContext(ctx, "./focalboard-server", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10), "--single-user")
cmd := exec.CommandContext(ctx, "./focalboard-server", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10), "-single-user", sessionToken)
cmd.Stdout = os.Stdout
err := cmd.Run()
if err != nil {
@ -29,6 +33,10 @@ func main() {
w.SetTitle("Focalboard")
w.SetSize(1024, 768, webview.HintNone)
script := fmt.Sprintf("localStorage.setItem('sessionId', '%s');", sessionToken)
w.Init(script)
w.Navigate("http://localhost:8088")
w.Run()
cancel()