From 0fc56326dff522771dbc6e79d428ad2b87cdf310 Mon Sep 17 00:00:00 2001
From: braks <78412429+bcakmakoglu@users.noreply.github.com>
Date: Fri, 19 Aug 2022 15:56:21 +0200
Subject: [PATCH 01/11] feat(gui-v2): add google auth signup option
---
packages/nc-gui-v2/middleware/auth.global.ts | 32 +++++++++++++++++--
packages/nc-gui-v2/package-lock.json | 19 +++++++++++
packages/nc-gui-v2/package.json | 1 +
packages/nc-gui-v2/pages/signup/[[token]].vue | 14 ++++++++
4 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/packages/nc-gui-v2/middleware/auth.global.ts b/packages/nc-gui-v2/middleware/auth.global.ts
index 8c85c53571..3c88944342 100644
--- a/packages/nc-gui-v2/middleware/auth.global.ts
+++ b/packages/nc-gui-v2/middleware/auth.global.ts
@@ -1,5 +1,6 @@
+import { message } from 'ant-design-vue'
import { defineNuxtRouteMiddleware, navigateTo } from '#app'
-import { useGlobal } from '#imports'
+import { useApi, useGlobal } from '#imports'
/**
* Global auth middleware
@@ -20,9 +21,11 @@ import { useGlobal } from '#imports'
* })
* ```
*/
-export default defineNuxtRouteMiddleware((to, from) => {
+export default defineNuxtRouteMiddleware(async (to, from) => {
const state = useGlobal()
+ await tryGoogleAuth()
+
/** if public allow */
if (to.meta.public) return
@@ -48,3 +51,28 @@ export default defineNuxtRouteMiddleware((to, from) => {
}
}
})
+
+async function tryGoogleAuth() {
+ const { signIn } = useGlobal()
+
+ const { api } = useApi()
+
+ if (window.location.search && /\bscope=|\bstate=/.test(window.location.search) && /\bcode=/.test(window.location.search)) {
+ try {
+ const {
+ data: { token },
+ } = await api.instance.post(
+ `/auth/${window.location.search.includes('state=github') ? 'github' : 'google'}/genTokenByCode${window.location.search}`,
+ )
+
+ signIn(token)
+ } catch (e: any) {
+ if (e.response && e.response.data && e.response.data.msg) {
+ message.error({ content: e.response.data.msg })
+ }
+ }
+
+ const newURL = window.location.href.split('?')[0]
+ window.history.pushState('object', document.title, newURL)
+ }
+}
diff --git a/packages/nc-gui-v2/package-lock.json b/packages/nc-gui-v2/package-lock.json
index f30469a424..93cc11aef9 100644
--- a/packages/nc-gui-v2/package-lock.json
+++ b/packages/nc-gui-v2/package-lock.json
@@ -36,6 +36,7 @@
"@iconify-json/clarity": "^1.1.4",
"@iconify-json/eva": "^1.1.2",
"@iconify-json/ic": "^1.1.7",
+ "@iconify-json/logos": "^1.1.14",
"@iconify-json/lucide": "^1.1.36",
"@iconify-json/material-symbols": "^1.1.8",
"@iconify-json/mdi": "^1.1.25",
@@ -1041,6 +1042,15 @@
"@iconify/types": "*"
}
},
+ "node_modules/@iconify-json/logos": {
+ "version": "1.1.14",
+ "resolved": "https://registry.npmjs.org/@iconify-json/logos/-/logos-1.1.14.tgz",
+ "integrity": "sha512-SvSxKubQbP/7Wdb3loShUeRGv82ejkNo5gjzvJzQeauntuU4aZjDrx0mnkhFZgNYd3li/mxvzPn79Xc5SGVliw==",
+ "dev": true,
+ "dependencies": {
+ "@iconify/types": "*"
+ }
+ },
"node_modules/@iconify-json/lucide": {
"version": "1.1.38",
"resolved": "https://registry.npmjs.org/@iconify-json/lucide/-/lucide-1.1.38.tgz",
@@ -15853,6 +15863,15 @@
"@iconify/types": "*"
}
},
+ "@iconify-json/logos": {
+ "version": "1.1.14",
+ "resolved": "https://registry.npmjs.org/@iconify-json/logos/-/logos-1.1.14.tgz",
+ "integrity": "sha512-SvSxKubQbP/7Wdb3loShUeRGv82ejkNo5gjzvJzQeauntuU4aZjDrx0mnkhFZgNYd3li/mxvzPn79Xc5SGVliw==",
+ "dev": true,
+ "requires": {
+ "@iconify/types": "*"
+ }
+ },
"@iconify-json/lucide": {
"version": "1.1.38",
"resolved": "https://registry.npmjs.org/@iconify-json/lucide/-/lucide-1.1.38.tgz",
diff --git a/packages/nc-gui-v2/package.json b/packages/nc-gui-v2/package.json
index 29fbe47465..cf1b4f1729 100644
--- a/packages/nc-gui-v2/package.json
+++ b/packages/nc-gui-v2/package.json
@@ -42,6 +42,7 @@
"@iconify-json/clarity": "^1.1.4",
"@iconify-json/eva": "^1.1.2",
"@iconify-json/ic": "^1.1.7",
+ "@iconify-json/logos": "^1.1.14",
"@iconify-json/lucide": "^1.1.36",
"@iconify-json/material-symbols": "^1.1.8",
"@iconify-json/mdi": "^1.1.25",
diff --git a/packages/nc-gui-v2/pages/signup/[[token]].vue b/packages/nc-gui-v2/pages/signup/[[token]].vue
index da97ee9eb7..947b33983b 100644
--- a/packages/nc-gui-v2/pages/signup/[[token]].vue
+++ b/packages/nc-gui-v2/pages/signup/[[token]].vue
@@ -96,6 +96,8 @@ async function signUp() {
})
}
+function googleSignUp() {}
+
function resetError() {
if (error) error = null
}
@@ -152,6 +154,18 @@ function resetError() {
+
+
+
+
+ Sign up with Google
+
+
+
Date: Fri, 19 Aug 2022 16:05:27 +0200
Subject: [PATCH 02/11] chore(gui-v2): check if signed in before trying google
auth
---
packages/nc-gui-v2/middleware/auth.global.ts | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/packages/nc-gui-v2/middleware/auth.global.ts b/packages/nc-gui-v2/middleware/auth.global.ts
index 3c88944342..d670c48bc6 100644
--- a/packages/nc-gui-v2/middleware/auth.global.ts
+++ b/packages/nc-gui-v2/middleware/auth.global.ts
@@ -24,16 +24,15 @@ import { useApi, useGlobal } from '#imports'
export default defineNuxtRouteMiddleware(async (to, from) => {
const state = useGlobal()
- await tryGoogleAuth()
+ /** if user isn't signed in and google auth is enabled, try to check if sign-in data is present */
+ if (!state.signedIn && state.appInfo.value.googleAuthEnabled) await tryGoogleAuth()
- /** if public allow */
+ /** if public allow all visitors */
if (to.meta.public) return
- /** if shred base allow without validating */
+ /** if shared base allow without validating */
if (to.params?.projectType === 'base') return
- if (to.meta.public) return
-
/** if auth is required or unspecified (same as required) and user is not signed in, redirect to signin page */
if ((to.meta.requiresAuth || typeof to.meta.requiresAuth === 'undefined') && !state.signedIn.value) {
return navigateTo('/signin')
From b87118a917d7915ab83d8cf319da28a45334b3f7 Mon Sep 17 00:00:00 2001
From: braks <78412429+bcakmakoglu@users.noreply.github.com>
Date: Fri, 19 Aug 2022 17:09:59 +0200
Subject: [PATCH 03/11] chore(gui-v2): style fix
---
packages/nc-gui-v2/components/general/SocialCard.vue | 2 +-
packages/nc-gui-v2/components/general/Sponsors.vue | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/packages/nc-gui-v2/components/general/SocialCard.vue b/packages/nc-gui-v2/components/general/SocialCard.vue
index 6ca98e0114..548619618b 100644
--- a/packages/nc-gui-v2/components/general/SocialCard.vue
+++ b/packages/nc-gui-v2/components/general/SocialCard.vue
@@ -7,7 +7,7 @@ const isRtlLang = $computed(() => ['fa'].includes(currentLang.value))
-
+
diff --git a/packages/nc-gui-v2/components/general/Sponsors.vue b/packages/nc-gui-v2/components/general/Sponsors.vue
index 8700a04108..0f47a53cf2 100644
--- a/packages/nc-gui-v2/components/general/Sponsors.vue
+++ b/packages/nc-gui-v2/components/general/Sponsors.vue
@@ -7,9 +7,9 @@ const { nav = false } = defineProps()
-
+
-
+
From bddd053cbad1b8c52363867d042db5b428b83409 Mon Sep 17 00:00:00 2001
From: braks <78412429+bcakmakoglu@users.noreply.github.com>
Date: Fri, 19 Aug 2022 17:12:58 +0200
Subject: [PATCH 04/11] chore(gui-v2): remove unused import
---
packages/nc-gui-v2/composables/useTheme/index.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/nc-gui-v2/composables/useTheme/index.ts b/packages/nc-gui-v2/composables/useTheme/index.ts
index 52b3f62c82..ca4cfa29dd 100644
--- a/packages/nc-gui-v2/composables/useTheme/index.ts
+++ b/packages/nc-gui-v2/composables/useTheme/index.ts
@@ -1,7 +1,7 @@
import { ConfigProvider } from 'ant-design-vue'
import type { Theme as AntTheme } from 'ant-design-vue/es/config-provider'
import { useStorage } from '@vueuse/core'
-import { NOCO, hexToRGB, themeV2Colors, toRefs, useCssVar, useInjectionState } from '#imports'
+import { NOCO, hexToRGB, themeV2Colors, useCssVar, useInjectionState } from '#imports'
interface ThemeConfig extends AntTheme {
primaryColor: string
From bf5b8a9ec412f4ca500b95ee1b24433c7ea52f5a Mon Sep 17 00:00:00 2001
From: braks <78412429+bcakmakoglu@users.noreply.github.com>
Date: Fri, 19 Aug 2022 17:45:17 +0200
Subject: [PATCH 05/11] chore(gui-v2): add injection key
---
packages/nc-gui-v2/composables/useTheme/index.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/nc-gui-v2/composables/useTheme/index.ts b/packages/nc-gui-v2/composables/useTheme/index.ts
index ca4cfa29dd..ded242762c 100644
--- a/packages/nc-gui-v2/composables/useTheme/index.ts
+++ b/packages/nc-gui-v2/composables/useTheme/index.ts
@@ -43,7 +43,7 @@ const [setup, use] = useInjectionState((config?: Partial) => {
theme: currentTheme,
setTheme,
}
-})
+}, 'theme')
export const provideTheme = setup
From 986cb617d50ce6722fc26742479e6da0caf64c67 Mon Sep 17 00:00:00 2001
From: braks <78412429+bcakmakoglu@users.noreply.github.com>
Date: Fri, 19 Aug 2022 17:50:24 +0200
Subject: [PATCH 06/11] chore(gui-v2): update middleware docs
---
packages/nc-gui-v2/middleware/auth.global.ts | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/packages/nc-gui-v2/middleware/auth.global.ts b/packages/nc-gui-v2/middleware/auth.global.ts
index d670c48bc6..ea761d1c7a 100644
--- a/packages/nc-gui-v2/middleware/auth.global.ts
+++ b/packages/nc-gui-v2/middleware/auth.global.ts
@@ -11,7 +11,19 @@ import { useApi, useGlobal } from '#imports'
* the user is redirected to the home page.
*
* By default, we assume that auth is required
- * If not required, mark the page as `requiresAuth: false` using `definePageMeta`
+ * If not required, mark the page as
+ * ```
+ * definePageMeta({
+ * requiresAuth: false
+ * })
+ * ```
+ *
+ * If auth should be circumvented completely mark the page as public
+ * ```
+ * definePageMeta({
+ * public: true
+ * })
+ * ```
*
* @example
* ```
@@ -51,6 +63,9 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
}
})
+/**
+ * If present, try using google auth data to sign user in before navigating to the next page
+ */
async function tryGoogleAuth() {
const { signIn } = useGlobal()
From cabb3e9d06a4de81573e4277d2317d5907a4140a Mon Sep 17 00:00:00 2001
From: braks <78412429+bcakmakoglu@users.noreply.github.com>
Date: Fri, 19 Aug 2022 20:14:38 +0200
Subject: [PATCH 07/11] chore(gui-v2): remove transition from header
---
packages/nc-gui-v2/layouts/base.vue | 114 ++++++++++++-------------
packages/nc-gui-v2/layouts/default.vue | 10 ++-
2 files changed, 61 insertions(+), 63 deletions(-)
diff --git a/packages/nc-gui-v2/layouts/base.vue b/packages/nc-gui-v2/layouts/base.vue
index 8dfc346000..6e15e0df6b 100644
--- a/packages/nc-gui-v2/layouts/base.vue
+++ b/packages/nc-gui-v2/layouts/base.vue
@@ -21,74 +21,70 @@ const logout = () => {
-
-
+
-
-
- {{ $t('general.loading') }}
+
+
+ {{ $t('general.loading') }}
-
-
+
+
-
-
-
-
-
-
-
- Switch language
+
-
-
-
-
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Switch language
diff --git a/packages/nc-gui-v2/layouts/default.vue b/packages/nc-gui-v2/layouts/default.vue
index dce2aae15c..252e820c59 100644
--- a/packages/nc-gui-v2/layouts/default.vue
+++ b/packages/nc-gui-v2/layouts/default.vue
@@ -13,15 +13,17 @@ useHead({
-
-
-
+
+
+
+
+
From 8cfbf347a33e969ca349461b48fbbfe216135ffb Mon Sep 17 00:00:00 2001
From: braks <78412429+bcakmakoglu@users.noreply.github.com>
Date: Fri, 19 Aug 2022 20:15:05 +0200
Subject: [PATCH 08/11] chore(gui-v2): update styles
---
packages/nc-gui-v2/pages/index/index.vue | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/packages/nc-gui-v2/pages/index/index.vue b/packages/nc-gui-v2/pages/index/index.vue
index b5a4b13ee2..a2383bcaf6 100644
--- a/packages/nc-gui-v2/pages/index/index.vue
+++ b/packages/nc-gui-v2/pages/index/index.vue
@@ -112,14 +112,14 @@ onMounted(() => {
-
+
@@ -128,10 +128,10 @@ onMounted(() => {
@@ -165,7 +165,7 @@ onMounted(() => {
{{ text }}
@@ -204,7 +204,7 @@ onMounted(() => {