From 95c486b8f41bebbef7730c01e78afb2adb1f1924 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 12 Mar 2024 23:23:16 +0800 Subject: [PATCH] :sparkles: Sign in --- pkg/services/factors.go | 5 +- pkg/views/src/components/Copyright.vue | 6 + .../src/components/auth/AccountLocator.vue | 59 +++++++++ .../src/components/auth/FactorApplicator.vue | 120 ++++++++++++++++++ .../src/components/auth/FactorPicker.vue | 74 +++++++++++ pkg/views/src/router/index.ts | 11 +- pkg/views/src/views/auth/sign-in.vue | 69 ++++++++++ 7 files changed, 341 insertions(+), 3 deletions(-) create mode 100644 pkg/views/src/components/Copyright.vue create mode 100644 pkg/views/src/components/auth/AccountLocator.vue create mode 100644 pkg/views/src/components/auth/FactorApplicator.vue create mode 100644 pkg/views/src/components/auth/FactorPicker.vue create mode 100644 pkg/views/src/views/auth/sign-in.vue diff --git a/pkg/services/factors.go b/pkg/services/factors.go index 15b066c..21f538a 100644 --- a/pkg/services/factors.go +++ b/pkg/services/factors.go @@ -1,9 +1,10 @@ package services import ( + "fmt" + "code.smartsheep.studio/hydrogen/identity/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/models" - "fmt" "github.com/google/uuid" "github.com/spf13/viper" ) @@ -51,7 +52,7 @@ func GetFactorCode(factor models.AuthFactor) (bool, error) { return true, err } - factor.Secret = uuid.NewString()[:8] + factor.Secret = uuid.NewString()[:6] if err := database.C.Save(&factor).Error; err != nil { return true, err } diff --git a/pkg/views/src/components/Copyright.vue b/pkg/views/src/components/Copyright.vue new file mode 100644 index 0000000..f3f6baa --- /dev/null +++ b/pkg/views/src/components/Copyright.vue @@ -0,0 +1,6 @@ + diff --git a/pkg/views/src/components/auth/AccountLocator.vue b/pkg/views/src/components/auth/AccountLocator.vue new file mode 100644 index 0000000..0e6be6c --- /dev/null +++ b/pkg/views/src/components/auth/AccountLocator.vue @@ -0,0 +1,59 @@ + + + diff --git a/pkg/views/src/components/auth/FactorApplicator.vue b/pkg/views/src/components/auth/FactorApplicator.vue new file mode 100644 index 0000000..4571c5a --- /dev/null +++ b/pkg/views/src/components/auth/FactorApplicator.vue @@ -0,0 +1,120 @@ + + + diff --git a/pkg/views/src/components/auth/FactorPicker.vue b/pkg/views/src/components/auth/FactorPicker.vue new file mode 100644 index 0000000..730a5c5 --- /dev/null +++ b/pkg/views/src/components/auth/FactorPicker.vue @@ -0,0 +1,74 @@ + + + diff --git a/pkg/views/src/router/index.ts b/pkg/views/src/router/index.ts index 994d293..d78ea4a 100644 --- a/pkg/views/src/router/index.ts +++ b/pkg/views/src/router/index.ts @@ -7,8 +7,17 @@ const router = createRouter({ { path: "/", component: MasterLayout, - children: [{ path: "/", name: "dashboard", component: () => import("@/views/dashboard.vue") }], + children: [ + { path: "/", name: "dashboard", component: () => import("@/views/dashboard.vue") }, + ], }, + { + path: "/auth", + children: [ + { path: "sign-in", name: "auth.sign-in", component: () => import("@/views/auth/sign-in.vue") }, + // { path: "sign-up", name: "auth.sign-up", component: () => import("@/views/auth/sign-up.vue") }, + ] + } ], }) diff --git a/pkg/views/src/views/auth/sign-in.vue b/pkg/views/src/views/auth/sign-in.vue new file mode 100644 index 0000000..81b30f0 --- /dev/null +++ b/pkg/views/src/views/auth/sign-in.vue @@ -0,0 +1,69 @@ + + + + + +@/components/Copyright.vue