-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aaron Shiel
authored and
Aaron Shiel
committed
Oct 1, 2024
1 parent
57ba297
commit 21fe84c
Showing
11 changed files
with
3,436 additions
and
726 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import { firebaseApp } from "../app"; | ||
import { DecodedIdToken, getAuth } from "firebase-admin/auth"; | ||
/* | ||
This software is Copyright ©️ 2020 The University of Southern California. All Rights Reserved. | ||
Permission to use, copy, modify, and distribute this software and its documentation for educational, research and non-profit purposes, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and subject to the full license file found in the root of this software deliverable. Permission to make commercial use of this software may be obtained by contacting: USC Stevens Center for Innovation University of Southern California 1150 S. Olive Street, Suite 2300, Los Angeles, CA 90115, USA Email: [email protected] | ||
The full terms of this copyright and license should always be found in the root directory of this software deliverable as "license.txt" and if these terms are not found with this software, please contact the USC Stevens Center for the full license. | ||
*/ | ||
import { firebaseApp } from '../app'; | ||
import { DecodedIdToken, getAuth } from 'firebase-admin/auth'; | ||
|
||
export async function getFirebaseUserFromReqAccessToken( | ||
authHeader: string | ||
|
@@ -8,7 +14,7 @@ export async function getFirebaseUserFromReqAccessToken( | |
return undefined; | ||
} | ||
const auth = getAuth(firebaseApp); | ||
const token = authHeader.split(" ")[1]; | ||
const token = authHeader.split(' ')[1]; | ||
if (!token) { | ||
return undefined; | ||
} | ||
|
@@ -19,4 +25,4 @@ export async function getFirebaseUserFromReqAccessToken( | |
console.error(e); | ||
return undefined; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,17 +5,17 @@ Permission to use, copy, modify, and distribute this software and its documentat | |
The full terms of this copyright and license should always be found in the root directory of this software deliverable as "license.txt" and if these terms are not found with this software, please contact the USC Stevens Center for the full license. | ||
*/ | ||
|
||
import createApp, { appStart, appStop } from "app"; | ||
import { expect } from "chai"; | ||
import { Express } from "express"; | ||
import mongoUnit from "mongo-unit"; | ||
import request from "supertest"; | ||
import { getFirebaseToken, getToken } from "../../helpers"; | ||
import createApp, { appStart, appStop } from 'app'; | ||
import { expect } from 'chai'; | ||
import { Express } from 'express'; | ||
import mongoUnit from 'mongo-unit'; | ||
import request from 'supertest'; | ||
import { getFirebaseToken, getToken } from '../../helpers'; | ||
|
||
describe.only("login-firebase", () => { | ||
describe('login firebase', () => { | ||
let app: Express; | ||
beforeEach(async () => { | ||
await mongoUnit.load(require("test/fixtures/mongodb/data-default.js")); | ||
await mongoUnit.load(require('test/fixtures/mongodb/data-default.js')); | ||
app = await createApp(); | ||
await appStart(); | ||
}); | ||
|
@@ -26,23 +26,26 @@ describe.only("login-firebase", () => { | |
}); | ||
|
||
it(`can log in`, async () => { | ||
const token = getFirebaseToken({ uid: "5ffdf1231ee2c62320b49e99" }); | ||
const token = await getFirebaseToken({ | ||
uid: '5ffdf1231ee2c62320b49e99', | ||
name: 'test', | ||
email: '[email protected]', | ||
}); | ||
|
||
const fetchResult = await request(app) | ||
.post("/graphql") | ||
.set("Authorization", `bearer ${token}`) | ||
.post('/graphql') | ||
.set('Authorization', `bearer ${token}`) | ||
.send({ | ||
query: `mutation FirebaseLogin { | ||
firebaseLogin { | ||
firebaseId | ||
query: `mutation LoginFirebase { | ||
loginFirebase { | ||
name | ||
userRole | ||
friends | ||
lastLoginAt | ||
} | ||
}`, | ||
}); | ||
expect(fetchResult.status).to.equal(200); | ||
expect(fetchResult.body.data.loginFirebase.name).to.eql('test'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters