Skip to content

Commit

Permalink
Ft 2 fa v2 187584919 (#60)
Browse files Browse the repository at this point in the history
* Ft login v google 187584916 (#47)

* login via google

* Ft-login via google

* login via google

* ft login via google

* ft  login with  google

* Logout feature (#26) (#46)

* Logout feature (#26)

* [#187584914]added logout feature

* [starts #187584914] added logout feature

* [finishes#187584914] logout feature

* [delivers##187584914] updated readme & swagger.json

* [delivers##187584914] updated readme & swagger.json

* [deliveres #187584914] logout features completed

* [deliveres #187584914] logout features completed

* [delivers #187584914] finished logout feature

* fixing bugs

* rebased

---------

Co-authored-by: Solange Duhimbaze Ihirwe <[email protected]>

* [Finishes #187584924] Seller Create/Add a product (#48)

* [Delivers #187584924] Seller Create/Add a product

* updated ReaderMe file

* Rebased on develop

* Fixed login fetaure (#59)

* Ft delete items seller #187584926 (#52)

* rebase

* rebase

* [delivers #187584926] seller delete item

* [Delivers #187584924] Seller Create/Add a product

* [start #187584926] seller delete item

---------

Co-authored-by: Solangeihirwe <[email protected]>
Co-authored-by: AimePazzo <[email protected]>

* [starts #187584911] Seller statistics per timeframe (#54)

* [starts #187584911] Seller statistics per timeframe

* [finishes #187584911] Seller statistics per timeframe

* Seller-statistics updated

* rebase1

* rebasing

* rebasing

* resolving circle CI issues

---------

Co-authored-by: AimePazzo <[email protected]>
Co-authored-by: Niyonshuti Jean De Dieu <[email protected]>
Co-authored-by: MANISHIMWESalton <[email protected]>
Co-authored-by: Solange Duhimbaze Ihirwe <[email protected]>
Co-authored-by: Mr. David <[email protected]>
Co-authored-by: Solangeihirwe <[email protected]>
  • Loading branch information
7 people authored Jun 10, 2024
1 parent 99c7974 commit d82b834
Show file tree
Hide file tree
Showing 20 changed files with 819 additions and 478 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Our e-commerce web application server, developed by Team Ninjas, facilitates smo
- Admin get users Endpoint
- Admin get user Endpoint
- Logout Endpoint
- Update User Profile Endpoint
- Get User Profile Endpoint
- User Update Profile Endpoint
- Seller create shop Endpoint
- Seller create product Endpoint
- Seller update product Endpoint
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@
"eslint-plugin-import": "^2.29.1",
"lint-staged": "^15.2.2"
}
}
}
4 changes: 4 additions & 0 deletions src/databases/migrations/20240523180022-create-sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export default {
type: new DataTypes.STRING(280),
allowNull: true
},
otpExpiration: {
type: DataTypes.DATE,
allowNull: true
},
createdAt: {
allowNull: false,
type: DataTypes.DATE,
Expand Down
6 changes: 6 additions & 0 deletions src/databases/models/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface SessionAttributes {
device: string;
token: string;
otp: string;
otpExpiration: Date;
createdAt: Date;
updatedAt: Date;
}
Expand All @@ -19,6 +20,7 @@ class Session extends Model<SessionAttributes> implements SessionAttributes {
declare device: string;
declare token: string;
declare otp: string;
declare otpExpiration: Date;
declare createdAt: Date;
declare updatedAt: Date;

Expand Down Expand Up @@ -51,6 +53,10 @@ Session.init(
type: new DataTypes.STRING(280),
allowNull: true
},
otpExpiration: {
type: DataTypes.DATE,
allowNull: true
},
createdAt: {
field: "createdAt",
type: DataTypes.DATE,
Expand Down
15 changes: 11 additions & 4 deletions src/databases/seeders/20240520202759-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const userOne = {
role: "admin",
status: "enabled",
isVerified: true,
};
is2FAEnabled: false
}
const userTwo = {
id: userTwoId,
createdAt: new Date(),
Expand All @@ -46,7 +47,8 @@ const userTwo = {
role: "buyer",
status: "enabled",
isVerified: true,
};
is2FAEnabled: false
}

const userThree = {
id: userThreeId,
Expand All @@ -65,7 +67,8 @@ const userThree = {
role: "buyer",
status: "enabled",
isVerified: true,
};
is2FAEnabled: true
}

const userFour = {
id: userFourId,
Expand All @@ -84,7 +87,8 @@ const userFour = {
role: "seller",
status: "enabled",
isVerified: true,
};
is2FAEnabled: false
}

const userFive = {
id: userFiveId,
Expand All @@ -103,6 +107,7 @@ const userFive = {
role: "seller",
status: "enabled",
isVerified: true,
is2FAEnabled: false
};

const userSix = {
Expand All @@ -122,6 +127,7 @@ const userSix = {
role: "seller",
status: "enabled",
isVerified: true,
is2FAEnabled: false
};

const userSeven = {
Expand All @@ -141,6 +147,7 @@ const userSeven = {
role: "seller",
status: "enabled",
isVerified: true,
is2FAEnabled: false
};

export const up = (queryInterface: QueryInterface) =>
Expand Down
12 changes: 11 additions & 1 deletion src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,14 @@ const hashPassword = (password: string)=>{
return bcrypt.hashSync(password, 10);
}

export { generateToken, decodeToken, comparePassword, hashPassword }
const generateRandomCode = (): string => {
return Math.floor(100000 + Math.random() * 900000).toString();
};

const generateOTP = () => {
const otp = generateRandomCode();
const expirationTime = new Date(Date.now() + 5 * 60 * 1000);
return { otp, expirationTime };
};

export { generateToken, decodeToken, comparePassword, hashPassword, generateRandomCode,generateOTP }
1 change: 0 additions & 1 deletion src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import authRepositories from "./modules/auth/repository/authRepositories";

chai.use(chaiHttp);
chai.use(sinonChai);

const router = () => chai.request(app);

describe("Initial configuration", () => {
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Document from "../swagger.json";
import router from "./routes";
import httpStatus from "http-status";


dotenv.config();
const app: Express = express();

Expand All @@ -24,11 +23,14 @@ app.use("/api", router);
app.get("**", (req: Request, res: Response) => {
res
.status(httpStatus.OK)
.json({ status: true, message: "Welcome to the e-Commerce Ninjas BackEnd." });
.json({
status: true,
message: "Welcome to the e-Commerce Ninjas BackEnd."
});
});

app.listen(PORT, () => {
console.log(`Server is running on the port ${PORT}`);
});

export default app;
export default app;
Loading

0 comments on commit d82b834

Please sign in to comment.