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

Win app: single user token

This commit is contained in:
Chen-I Lim 2021-02-09 15:24:50 -08:00
parent 753b901877
commit 93b9eac852
5 changed files with 37 additions and 30 deletions

36
.vscode/launch.json vendored
View File

@ -11,20 +11,28 @@
"mode": "debug",
"program": "${workspaceFolder}/server/main",
"cwd": "${workspaceFolder}"
},
{
"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": "Go: Launch Windows App",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/win",
"cwd": "${workspaceFolder}/win/temp",
},
{
"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

@ -338,13 +338,4 @@ function getReadToken(): string {
const client = new OctoClient(undefined, localStorage.getItem('sessionId') || '', getReadToken())
declare global {
function clientSingleUserToken(): string
}
if (clientSingleUserToken && typeof clientSingleUserToken === 'function') {
Utils.log('clientSingleUserToken')
client.token = clientSingleUserToken()
}
export default client

View File

@ -4,5 +4,6 @@ go 1.15
require (
github.com/gonutz/w32 v1.0.0
github.com/google/uuid v1.2.0
github.com/zserge/lorca v0.1.10-0.20200301195127-a3e43396a47e
)

View File

@ -1,5 +1,7 @@
github.com/gonutz/w32 v1.0.0 h1:3t1z6ZfkFvirjFYBx9pHeHBuKoN/VBVk9yHb/m2Ll/k=
github.com/gonutz/w32 v1.0.0/go.mod h1:Rc/YP5K9gv0FW4p6X9qL3E7Y56lfMflEol1fLElfMW4=
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/zserge/lorca v0.1.9 h1:vbDdkqdp2/rmeg8GlyCewY2X8Z+b0s7BqWyIQL/gakc=
github.com/zserge/lorca v0.1.9/go.mod h1:bVmnIbIRlOcoV285KIRSe4bUABKi7R7384Ycuum6e4A=
github.com/zserge/lorca v0.1.10-0.20200301195127-a3e43396a47e h1:RqKGfaG8v1WBC6JX5vhG7GocwY1lENlMiraQibyGRsY=

View File

@ -2,6 +2,7 @@ package main
import (
"context"
"fmt"
"log"
"os"
"os/exec"
@ -12,7 +13,7 @@ import (
"github.com/zserge/lorca"
)
var sessionToken string = uuid.New().String()
var sessionToken string = "su-" + uuid.New().String()
func runServer(ctx context.Context) *exec.Cmd {
// cmd := exec.CommandContext(ctx, "focalboard-server.exe", "--monitorpid", strconv.FormatInt(int64(os.Getpid()), 10), "-single-user", sessionToken)
@ -52,13 +53,21 @@ func main() {
ctx, cancel := context.WithCancel(context.Background())
cmd := runServer(ctx)
ui, err := lorca.New("http://localhost:8088", "", 1024, 768)
ui, err := lorca.New("", "", 1024, 768)
if err != nil {
log.Fatal(err)
}
// defer ui.Close()
ui.Bind("clientSingleUserToken", getSessionToken)
if err := ui.Load("http://localhost:8088"); err != nil {
log.Fatal(err)
}
script := fmt.Sprintf("localStorage.setItem('sessionId', '%s');", sessionToken)
value := ui.Eval(script)
if err := value.Err(); err != nil {
log.Fatal(err)
}
log.Printf("Started")
<-ui.Done()
@ -70,10 +79,6 @@ func main() {
}
}
func getSessionToken() string {
return sessionToken
}
func hideConsole() {
console := w32.GetConsoleWindow()
if console != 0 {