From ff4a77b4b460de4aa2548a566c27c966abd522d4 Mon Sep 17 00:00:00 2001 From: kevin-DL Date: Fri, 26 Apr 2024 15:13:13 +0100 Subject: [PATCH] Added basic auth and route protection --- auth.go | 33 +++++++++++++++++ frontend/src/App.vue | 33 ++++++++++++++++- frontend/src/main.js | 58 +++++++++++++++++++++++++----- frontend/src/pages/Login.vue | 5 +++ frontend/src/pages/Protected.vue | 5 +++ frontend/wailsjs/go/main/Auth.d.ts | 8 +++++ frontend/wailsjs/go/main/Auth.js | 15 ++++++++ main.go | 8 ++++- 8 files changed, 154 insertions(+), 11 deletions(-) create mode 100644 auth.go create mode 100644 frontend/src/pages/Login.vue create mode 100644 frontend/src/pages/Protected.vue create mode 100755 frontend/wailsjs/go/main/Auth.d.ts create mode 100755 frontend/wailsjs/go/main/Auth.js diff --git a/auth.go b/auth.go new file mode 100644 index 0000000..d5aa88b --- /dev/null +++ b/auth.go @@ -0,0 +1,33 @@ +package main + +import ( + "context" +) + +// App struct +type Auth struct { + ctx context.Context +} + +// NewApp creates a new App application struct +func NewAuth() *Auth { + return &Auth{} +} + +// startup is called when the app starts. The context is saved +// so we can call the runtime methods +func (a *Auth) startup(ctx context.Context) { + a.ctx = ctx +} + +func (a *Auth) Login() error { + return nil +} + +func (a *Auth) Register() error { + return nil +} + +func (a *Auth) IsLoggedIn() bool { + return false +} diff --git a/frontend/src/App.vue b/frontend/src/App.vue index c95bfe2..d379ecc 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,8 +1,39 @@