-
Notifications
You must be signed in to change notification settings - Fork 11
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
Showing
19 changed files
with
645 additions
and
374 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
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,9 +1,31 @@ | ||
HOST=databases.com | ||
PORT=3000 | ||
PG_USER=username | ||
PASSWORD=password | ||
DATABASE=database | ||
DIALECT=postgres | ||
ALTER_DB=true | ||
MAILGUN_API_KEY=01234567890123456789 | ||
MAILGUN_DOMAIN=databases.com | ||
#api key for mailing service | ||
MAILGUN_API_KEY=*** | ||
#mailgun domain | ||
MAILGUN_DOMAIN=code3scape.com | ||
#testing port for jest | ||
TEST_PORT=30300 | ||
#sequelize host adress | ||
HOST=104.168.169.204 | ||
#sequelize postgres username | ||
PG_USER=*** | ||
#sequelize postgres database name | ||
DATABASE=*** | ||
#sequelize database password | ||
PASSWORD=*** | ||
#sequelize allow to alter database: true/false | ||
ALTER_DB=true | ||
#password for session-express | ||
SECRET=*** | ||
#Neo4j graph database url | ||
NEO4J_URL=neo4j://104.168.169.204 | ||
#Neo4j username | ||
NEO4J_USER=*** | ||
#Neo4j password | ||
NEO4J_PASSWORD=*** | ||
#production/development flag, in jest tests this varible is "test" by default | ||
NODE_ENV = development | ||
#local port, default value 3052 | ||
PORT = 3052 | ||
#hostname adress, default is https://learndatabases.dev, | ||
#if you want to use localhost you need to specify port, for example http://localhost:4000 | ||
HOSTNAME = https://learndatabases.dev |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,42 +58,47 @@ describe("Sign up", () => { | |
}); | ||
|
||
it("should throw an error if accounts already exists", () => { | ||
mockFindOne.mockImplementation((query) => { | ||
if (query.where.email) return { email: "[email protected]" }; | ||
if (query.where.username) return false; | ||
mockCreateAccount.mockImplementation(() => { | ||
throw new Error("This account already exists"); | ||
}); | ||
const obj = { | ||
email: "[email protected]", | ||
}; | ||
return expect(signUp(obj)).rejects.toThrow("this account already exists"); | ||
return expect(signUp(obj)).rejects.toThrow("This account already exists"); | ||
}); | ||
|
||
it("should create a user account", async () => { | ||
const dataValues = await genUserInfoWithPw("abcd1234"); | ||
mockFindOne.mockImplementation((query) => { | ||
if (query.where.email) return undefined; | ||
if (query.where.username) return false; | ||
const obj = { email: "[email protected]" }; | ||
const dataValues = { ...obj, username: "testuser", dbPassword: "database" }; | ||
mockCreateAccount.mockReturnValue({ | ||
dataValues: dataValues, | ||
update: () => {}, | ||
}); | ||
const data = await signUp(obj); | ||
expect(data.dataValues).toEqual(dataValues); | ||
}); | ||
|
||
it("should create a anonymous user account", async () => { | ||
const obj = {}; | ||
const dataValues = { username: "testuser", dbPassword: "database" }; | ||
mockCreateAccount.mockReturnValue({ | ||
dataValues: dataValues, | ||
update: () => {}, | ||
}); | ||
const obj = { | ||
email: "[email protected]", | ||
}; | ||
const data = await signUp(obj); | ||
expect(data.dataValues).toEqual(dataValues); | ||
expect(email.sendPasswordResetEmail).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it("should send a user set Password email", async () => { | ||
const obj = { | ||
id: 4, | ||
email: "[email protected]", | ||
update: jest.fn(), | ||
}; | ||
|
||
await sendPasswordResetEmail(obj); | ||
expect(email.sendPasswordResetEmail.mock.calls.length).toEqual(1); | ||
const obj = { email: "[email protected]" }; | ||
const dataValues = { ...obj, username: "testuser", dbPassword: "database" }; | ||
mockCreateAccount.mockReturnValue({ | ||
dataValues: dataValues, | ||
update: () => {}, | ||
}); | ||
await signUp(obj); | ||
expect(email.sendPasswordResetEmail).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
|
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,13 +1,16 @@ | ||
const mailgun = require("mailgun-js"); | ||
const logger = require("../lib/log")(__filename); | ||
const getEnvVar = require("../lib/getEnvVar"); | ||
require("dotenv").config(); | ||
|
||
const mg = mailgun(getEnvVar("mailgun")); | ||
const mg = mailgun({ | ||
apiKey: process.env.MAILGUN_API_KEY, | ||
domain: process.env.MAILGUN_DOMAIN, | ||
}); | ||
|
||
const mgModule = {}; | ||
|
||
mgModule.sendPasswordResetEmail = (receiver, token) => { | ||
const link = `https://learndatabases.dev/setPassword/${token}`; | ||
const link = `${process.env.HOSTNAME||"https://learndatabases.dev"}/setPassword/${token}` | ||
const data = { | ||
from: "[email protected]", | ||
to: receiver, | ||
|
@@ -19,7 +22,7 @@ mgModule.sendPasswordResetEmail = (receiver, token) => { | |
<hr> | ||
<div id="content"> | ||
<p>You have requested a (re)set password token. The button below will redirect you to our website with an autheticated token. Please click the button and set your password.</p> | ||
<a href="${link}" target="_blank" id="button">Set my Password</a> | ||
<a href="${link}" target="_blank" id="button">Set my Password</a> ${link!=`https://learndatabases.dev/setPassword/${token}`?"<h2>DEVELOPMENT MODE IS ON. This link will redirect you to your development server</h2>" : ""} | ||
<p><small><b style="color: red">Warning</b>: Anyone with access to this email has access to your account. Don't share this email with other people.</small></p> | ||
</div> | ||
</div> | ||
|
Oops, something went wrong.