From 3003bc1223114976064cefaf3ed8861eba758372 Mon Sep 17 00:00:00 2001 From: Vibhu Dujari Date: Fri, 25 Mar 2022 18:38:28 +0530 Subject: [PATCH 01/39] web-components v0.1.1 --- nuxt.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nuxt.config.js b/nuxt.config.js index 0c0349c..8a75240 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -1,4 +1,5 @@ import config from './config' +import path from 'path'; export default { mode: 'universal', @@ -16,7 +17,7 @@ export default { ], link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }], script: [ - { src: 'https://unpkg.com/@coding-blocks/web-components@0.0.12/dist/index.js' }, + { src: 'https://unpkg.com/@coding-blocks/web-components@0.1.1/dist/index.js' }, { src: 'https://code.jivosite.com/widget.js', 'data-jv-id': 'ASYGLZQ6UC' } ] }, From e25e3264ae35e08f914f755a2fc25139a01af631 Mon Sep 17 00:00:00 2001 From: Vibhu Dujari Date: Wed, 29 Jun 2022 21:11:56 +0530 Subject: [PATCH 02/39] added new navbar --- assets/css/app.css | 103 ++++++++++++++++++++++++++++++++ components/Navbar.vue | 134 ++++++++++++++++++------------------------ nuxt.config.js | 3 +- 3 files changed, 162 insertions(+), 78 deletions(-) create mode 100644 assets/css/app.css diff --git a/assets/css/app.css b/assets/css/app.css new file mode 100644 index 0000000..b879ab9 --- /dev/null +++ b/assets/css/app.css @@ -0,0 +1,103 @@ +/* Navbar */ + +.navbar .main { + background: #15171e; + color: white; +} + +.navbar a { + display: block; + color: white; +} + +.navbar span { + display: block; +} + +.navbar li img { + height: 24px; +} + +.nav-menu ul { + margin: 0; + padding: 0; + list-style: none; +} + +.nav-menu > ul { + display: flex; + /* align-items: center; */ +} + +.nav-menu > ul > li { + position: relative; + white-space: nowrap; + padding: 15px 25px; + text-align: center; +} + +.nav-menu li:hover { + position: relative; + background: #1a1c25; +} + +.nav-menu .active { + background: #1a1c25; +} + +.nav-menu .active::after { + position: absolute; + content: ""; + height: 2px; + bottom: 0; + width: 100%; + left: 0; + background: linear-gradient(90deg, #838281 0%, #ffba08 100%); +} + +/* Button */ +.button-solid-orange { + margin-left: 25px; + background: linear-gradient(90deg, #f26a3e 0%, #fb8133 100%); + border-radius: 5px; + color: #fff; + padding: 9px 25px 10px 25px; + white-space: nowrap; + transition: 0.3s; + font-size: 14px; + display: inline-block; + border: 0; + font-weight: normal; +} + +.button-solid-orange:hover { + background-position: 100%; + color: #fff; +} + +@media (max-width: 991px) { + .button-solid-orange { + margin: 0; + padding: 4px 10px 5px 10px; + } +} + + +/*-------------------Custom------------------*/ +.logo { + font-size: 30px; + margin: 0; + padding: 0; + line-height: 1; + font-weight: 500; + letter-spacing: 2px; + text-transform: uppercase; +} + +.logo a { + color: #fff; +} + +.logo img { + max-height: 56px; +} \ No newline at end of file diff --git a/components/Navbar.vue b/components/Navbar.vue index 7e40e4d..249d8d8 100644 --- a/components/Navbar.vue +++ b/components/Navbar.vue @@ -1,87 +1,67 @@ \ No newline at end of file diff --git a/components/Base/Modal.vue b/components/Base/Modal.vue new file mode 100644 index 0000000..3acbe78 --- /dev/null +++ b/components/Base/Modal.vue @@ -0,0 +1,113 @@ + + + + diff --git a/components/Navbar.vue b/components/Navbar.vue index 249d8d8..fa1e28e 100644 --- a/components/Navbar.vue +++ b/components/Navbar.vue @@ -23,7 +23,7 @@ - Login / Signup + @@ -77,6 +77,9 @@ export default { openNavbar() { const navbar = document.getElementById("navbar") navbar.showhamburger = true + }, + toggleLoginDialog() { + this.$emit('toggleShowLoginModal') } } } diff --git a/config.js b/config.js index 30d2d37..583d20f 100644 --- a/config.js +++ b/config.js @@ -1,16 +1,18 @@ const ENV = process.env.NODE_ENV || 'development' const config = { // BASE State - COOKIE_NAME: 'hack_auth_session' + COOKIE_NAME: 'cb_auth' } if (ENV === 'development') { config.axios = { host: "localhost", - port: 3001, + port: 3000, prefix: "/api/v2" } - config.publicUrl = "http://test.hackerblocks" + config.publicUrl = "http://localhost:8081" + config.ONEAUTH_URL= "http://localhost:3838" + config.ONEAUTH_CLIENT_ID = 3680446660 } else if (ENV === 'production') { config.axios = { host: "hack-api.codingblocks.com", @@ -19,6 +21,8 @@ if (ENV === 'development') { prefix: "/api/v2" } config.publicUrl = "http://hack.codingblocks.com" + config.ONEAUTH_URL= "https://account.codingblocks.com" + config.ONEAUTH_CLIENT_ID = 2146237097 } export default config diff --git a/layouts/default.vue b/layouts/default.vue index b09c9b2..b3c24de 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -1,22 +1,42 @@ diff --git a/middleware/auth.js b/middleware/auth.js index 1ba5814..044d672 100644 --- a/middleware/auth.js +++ b/middleware/auth.js @@ -2,8 +2,8 @@ import config from '~/config' export default async function ({ store, app: { $cookies }, $axios }) { const isAuthenticated = !!store.state.session.user - const session = $cookies.get(config.COOKIE_NAME) - const jwt = session?.authenticated?.jwt + const token = $cookies.get(config.COOKIE_NAME) + const jwt = token if (isAuthenticated || !jwt) { return; diff --git a/plugins/axios.js b/plugins/axios.js index 5dc70d6..25e119a 100644 --- a/plugins/axios.js +++ b/plugins/axios.js @@ -1,8 +1,8 @@ import config from '~/config' export default function({ $axios, app: { $cookies } }) { - const session = $cookies.get(config.COOKIE_NAME) - const jwt = session?.authenticated?.jwt + const token = $cookies.get(config.COOKIE_NAME) + const jwt = token if (jwt) { // we have loggedIn session From 61ae572994b0d3c955ea97ece89ad5d91b2a8bdd Mon Sep 17 00:00:00 2001 From: Vibhu Dujari Date: Sat, 27 Aug 2022 01:13:49 +0530 Subject: [PATCH 05/39] handle redirection and login prompt --- layouts/default.vue | 10 +++++++++- middleware/redirectLoggedInHome.js | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/layouts/default.vue b/layouts/default.vue index b3c24de..7fb4acb 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -1,7 +1,7 @@ @@ -12,6 +27,14 @@ import config from '~/config.js' export default { + data() { + return { + email: null, + otp: null, + otp_id: null, + error: null + } + }, methods: { loginGoogle() { const redirectUri = window.location.href @@ -23,6 +46,34 @@ export default { const url = config.ONEAUTH_URL window.location.href = `${url}/login/facebook/v2?redirect_uri=${redirectUri}&client=online-codingblocks&client_id=${config.ONEAUTH_CLIENT_ID}` } + }, + tasks(t) { + return { + sendEmailOtpTask: t(function* () { + this.error = null + try { + const response = yield this.$axios.post('/jwt/otp', { email: this.email }) + this.otp_id = response.data.id + } catch(err) { + console.log(err) + } + }), + verifyEmailOtpTask: t(function* () { + this.error = null + yield this.$axios.post('/jwt/otp/verify', + { + email: this.email, + otp_id: this.otp_id, + otp: this.otp + } + ).catch(({response}) => this.error = response.data) + }) + } + }, + computed: { + disableSendOtpButton() { + return !this.email + } } } \ No newline at end of file From 18a40ccdb2135d24bbc344be734afdbeee8b731d Mon Sep 17 00:00:00 2001 From: Vibhu Dujari Date: Sun, 28 Aug 2022 17:10:32 +0530 Subject: [PATCH 15/39] otp/verify with withCredentials --- components/Base/LoginDialog.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/Base/LoginDialog.vue b/components/Base/LoginDialog.vue index 7fe2246..29e4974 100644 --- a/components/Base/LoginDialog.vue +++ b/components/Base/LoginDialog.vue @@ -65,8 +65,11 @@ export default { email: this.email, otp_id: this.otp_id, otp: this.otp + }, { + withCredentials: true } - ).catch(({response}) => this.error = response.data) + ) + .catch(({response}) => this.error = response.data) }) } }, From 63a87be40bee2bce55bfcbed6233606db9476cfe Mon Sep 17 00:00:00 2001 From: Vibhu Dujari Date: Sun, 28 Aug 2022 17:43:21 +0530 Subject: [PATCH 16/39] reload page on successful OTP verification --- components/Base/LoginDialog.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Base/LoginDialog.vue b/components/Base/LoginDialog.vue index 29e4974..27963fb 100644 --- a/components/Base/LoginDialog.vue +++ b/components/Base/LoginDialog.vue @@ -68,7 +68,7 @@ export default { }, { withCredentials: true } - ) + ).then(() => window.location.reload()) .catch(({response}) => this.error = response.data) }) } From 8c36df9b13c24c19346ec49d69ef2fda3c03d159 Mon Sep 17 00:00:00 2001 From: Vibhu Dujari Date: Tue, 6 Sep 2022 16:26:31 +0530 Subject: [PATCH 17/39] use created instead of mounted --- layouts/default.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/default.vue b/layouts/default.vue index 70339a6..4c6b309 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -34,7 +34,7 @@ export default { class: 'pt-0' } }, - mounted() { + created() { if(process.client) { const redirectionPath = localStorage.getItem('redirectionPath') From 41268cc5f058d84a97ef78c1df38a48ed2a732a7 Mon Sep 17 00:00:00 2001 From: Vibhu Dujari Date: Tue, 6 Sep 2022 16:58:28 +0530 Subject: [PATCH 18/39] Revert "use created instead of mounted" This reverts commit 8c36df9b13c24c19346ec49d69ef2fda3c03d159. --- layouts/default.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/default.vue b/layouts/default.vue index 4c6b309..70339a6 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -34,7 +34,7 @@ export default { class: 'pt-0' } }, - created() { + mounted() { if(process.client) { const redirectionPath = localStorage.getItem('redirectionPath') From b687d8b55dfe6bbe685295cf908dbe87e9c21ba6 Mon Sep 17 00:00:00 2001 From: Vibhu Dujari Date: Thu, 8 Sep 2022 12:42:15 +0530 Subject: [PATCH 19/39] css-fix: center email and otp button --- components/Base/LoginDialog.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/Base/LoginDialog.vue b/components/Base/LoginDialog.vue index 27963fb..5c4a96f 100644 --- a/components/Base/LoginDialog.vue +++ b/components/Base/LoginDialog.vue @@ -9,12 +9,12 @@
OR
-
+
-
+
From b09a00ae8262735fb1db60ed9e404fa83c179d67 Mon Sep 17 00:00:00 2001 From: Vibhu Dujari Date: Fri, 9 Sep 2022 16:53:31 +0530 Subject: [PATCH 20/39] convert email to lower case b4 otp request --- components/Base/LoginDialog.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Base/LoginDialog.vue b/components/Base/LoginDialog.vue index 5c4a96f..f9b89ff 100644 --- a/components/Base/LoginDialog.vue +++ b/components/Base/LoginDialog.vue @@ -52,7 +52,7 @@ export default { sendEmailOtpTask: t(function* () { this.error = null try { - const response = yield this.$axios.post('/jwt/otp', { email: this.email }) + const response = yield this.$axios.post('/jwt/otp', { email: this.email.toLowerCase() }) this.otp_id = response.data.id } catch(err) { console.log(err) From b054793951ef406e7669de56aecfccf9941fb309 Mon Sep 17 00:00:00 2001 From: Vibhu Dujari Date: Fri, 9 Sep 2022 16:56:13 +0530 Subject: [PATCH 21/39] email to lower case in verfity otp --- components/Base/LoginDialog.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Base/LoginDialog.vue b/components/Base/LoginDialog.vue index f9b89ff..f4e5f4b 100644 --- a/components/Base/LoginDialog.vue +++ b/components/Base/LoginDialog.vue @@ -62,7 +62,7 @@ export default { this.error = null yield this.$axios.post('/jwt/otp/verify', { - email: this.email, + email: this.email.toLowerCase(), otp_id: this.otp_id, otp: this.otp }, { From 72872c8bfab6614e07adf89de09f75bac82aa40e Mon Sep 17 00:00:00 2001 From: Vibhu Dujari Date: Sun, 2 Oct 2022 19:42:37 +0530 Subject: [PATCH 22/39] integrate cb-login-signup web-component --- components/Navbar.vue | 2 +- layouts/default.vue | 14 +++----------- nuxt.config.js | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/components/Navbar.vue b/components/Navbar.vue index fa1e28e..fc3715c 100644 --- a/components/Navbar.vue +++ b/components/Navbar.vue @@ -79,7 +79,7 @@ export default { navbar.showhamburger = true }, toggleLoginDialog() { - this.$emit('toggleShowLoginModal') + document.getElementsByTagName('cb-login-signup')[0].classList.remove('hide-cb-login-signup-prompt') } } } diff --git a/layouts/default.vue b/layouts/default.vue index 70339a6..6e21804 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -1,11 +1,7 @@