Skip to content

Commit

Permalink
feat(auth): working serverMiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKanera committed Jun 11, 2020
1 parent d5f7ccc commit 5f85ce0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 37 deletions.
2 changes: 1 addition & 1 deletion api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function(req: any, res: any, next: () => void) {
.auth()
.verifyIdToken(idToken)
.then((decodedClaims: any) => {
res.locals.decodedClaims = decodedClaims;
res.locals.user = decodedClaims;
})
.catch(() => {
next();
Expand Down
25 changes: 1 addition & 24 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,7 @@ const config: Configuration = {
/*
** Nuxt.js modules
*/
modules: [
'@nuxtjs/axios',
'@nuxtjs/pwa',
'@nuxtjs/dotenv',
'@nuxtjs/firebase',
],

firebase: {
config: {
apiKey: 'AIzaSyBp95Odjc3I3WG7k4DGSSqb9LZC1FKExZQ',
authDomain: 'dashub-ecfb7.firebaseapp.com',
databaseURL: 'https://dashub-ecfb7.firebaseio.com',
projectId: 'dashub-ecfb7',
storageBucket: 'dashub-ecfb7.appspot.com',
messagingSenderId: '874351010489',
appId: '1:874351010489:web:e54fc45f23d51834923168',
measurementId: 'G-3F2M69JSHM',
},
services: {
auth: {
ssr: true,
},
},
},
modules: ['@nuxtjs/axios', '@nuxtjs/pwa', '@nuxtjs/dotenv'],

serverMiddleware: ['~/api/index.ts'],

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"@nuxt/typescript-runtime": "0.4.6",
"@nuxtjs/axios": "5.10.3",
"@nuxtjs/dotenv": "1.4.1",
"@nuxtjs/firebase": "5.2.0",
"@nuxtjs/pwa": "3.0.0-beta.20",
"@vue/composition-api": "0.5.0",
"firebase": "7.14.2",
Expand Down
5 changes: 4 additions & 1 deletion plugins/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ const firebaseConfig = {
};

export const provideFirebase = () => {
if (!firebase.apps.some((app) => app?.name === 'client'))
if (firebase.apps.some((app) => app?.name === 'default')) {
firebase.initializeApp(firebaseConfig, 'client');
} else if (!firebase.apps.some((app) => app?.name === 'client')) {
firebase.initializeApp(firebaseConfig);
}
};

export const useFirebaseAuth = () => {
Expand Down
11 changes: 1 addition & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1746,15 +1746,6 @@
consola "^2.11.3"
eslint-loader "^4.0.2"

"@nuxtjs/[email protected]":
version "5.2.0"
resolved "https://registry.yarnpkg.com/@nuxtjs/firebase/-/firebase-5.2.0.tgz#424c2196b2da288658148eb105dd152524d97f8d"
integrity sha512-utznHEJeoGej01YBgDbX5Elt1L/25aWj7O4aF/PzV7A1WCWi3sBLQDoqSdnIrDkyX/gr8xYrc/BOD024iwiAuA==
dependencies:
consola "^2.11.3"
optionalDependencies:
firebase-admin "^8.11.0"

"@nuxtjs/proxy@^1.3.3":
version "1.3.3"
resolved "https://registry.yarnpkg.com/@nuxtjs/proxy/-/proxy-1.3.3.tgz#3de3d9f073e8e57167168100940be2a824a220e0"
Expand Down Expand Up @@ -5856,7 +5847,7 @@ find-versions@^3.2.0:
dependencies:
semver-regex "^2.0.0"

[email protected], firebase-admin@^8.11.0:
[email protected]:
version "8.12.1"
resolved "https://registry.yarnpkg.com/firebase-admin/-/firebase-admin-8.12.1.tgz#a380c43a9e6ba37dfbe42211a253dd890a442063"
integrity sha512-DZ4Q7QQJYaO2BhnhZLrhL+mGRTCLS5WrxjbJtuKGmbKRBepwMhx++EQA5yhnGnIXgDHnp5SrZnVKygNdXtH8BQ==
Expand Down

0 comments on commit 5f85ce0

Please sign in to comment.