-
-
Notifications
You must be signed in to change notification settings - Fork 961
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Check authentication for Talawa-admin added (#713)
* check authentication feature added for talawa admin * tests for check authentication added * minor fixes * typo fixes * minor fixes * npm err fixes
- Loading branch information
1 parent
11ead17
commit f395447
Showing
5 changed files
with
52 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const userExists = require('../../helper_functions/userExists'); | ||
const { USER_NOT_FOUND } = require('../../../constants'); | ||
|
||
module.exports = async (parent, args, context) => { | ||
let userFound = await userExists(context.userId); | ||
if (!userFound) throw new Error(USER_NOT_FOUND); | ||
|
||
return { | ||
...userFound?._doc, | ||
organizationsBlockedBy: [], | ||
}; | ||
}; |
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
"start-test-server-in-action": "cross-env NODE_ENV=test pm2 start index.js -f", | ||
"stop-test-server-in-action": "pm2 delete all", | ||
"lint": "eslint . --fix && echo 'Lint complete.'", | ||
"setup": "npm i [email protected] [email protected] inquirer markdown-js [email protected] [email protected] [email protected] -f && node setup.js", | ||
"setup": "npm i [email protected] [email protected] inquirer markdown-js [email protected] [email protected] [email protected] && node setup.js", | ||
"file-coverage": "npm test $npm_config_testfile -- --coverage --collectCoverageFrom=$npm_config_functionfile" | ||
}, | ||
"repository": { | ||
|
@@ -56,11 +56,11 @@ | |
"helmet": "^4.6.0", | ||
"i18n": "^0.13.3", | ||
"image-hash": "^4.0.1", | ||
"inquirer": "^8.2.0", | ||
"inquirer": "^8.2.4", | ||
"jsonwebtoken": "^8.5.1", | ||
"logger": "file:lib/helper_lib/logger", | ||
"markdown-js": "^0.0.4", | ||
"marked": "^4.0.10", | ||
"marked": "^2.0.1", | ||
"marked-terminal": "^4.1.0", | ||
"moment": "^2.29.2", | ||
"mongoose": "^5.13.0", | ||
|
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const shortid = require('shortid'); | ||
|
||
const database = require('../../../db'); | ||
const getUserId = require('../../functions/getUserIdFromSignup'); | ||
const checkAuth = require('../../../lib/resolvers/auth_query/checkAuth'); | ||
|
||
let userId; | ||
|
||
beforeAll(async () => { | ||
require('dotenv').config(); | ||
await database.connect(); | ||
let generatedEmail = `${shortid.generate().toLowerCase()}@test.com`; | ||
userId = await getUserId(generatedEmail); | ||
}); | ||
|
||
afterAll(() => { | ||
database.disconnect(); | ||
}); | ||
|
||
describe('Testing check auth resolver', () => { | ||
test('Testing if the user logged in or not', async () => { | ||
const args = { | ||
id: '62277875e904753262f99bc3', | ||
}; | ||
|
||
const response = await checkAuth({}, args, { | ||
userId: userId, | ||
}); | ||
|
||
expect(response).toBeTruthy(); | ||
}); | ||
}); |