-
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.
ft-2FA two factor authentication for seller
- Loading branch information
Showing
11 changed files
with
389 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
return queryInterface.addColumn('Users', 'enable2FA', { | ||
type: Sequelize.BOOLEAN, | ||
allowNull: false, | ||
defaultValue: false, | ||
}); | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
return queryInterface.removeColumn('Users', 'enable2FA'); | ||
}, | ||
}; |
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,43 @@ | ||
'use strict'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.createTable('OTP', { | ||
id: { | ||
type: Sequelize.UUID, | ||
unique: true, | ||
defaultValue: Sequelize.UUIDV4, | ||
allowNull: false, | ||
primaryKey: true, | ||
}, | ||
token: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
unique: true, | ||
}, | ||
userId: { | ||
type: Sequelize.UUID, | ||
allowNull: false, | ||
references: { | ||
model: 'Users', | ||
key: 'id', | ||
}, | ||
onUpdate: 'CASCADE', | ||
onDelete: 'CASCADE', | ||
}, | ||
createdAt: { | ||
type: Sequelize.DATE, | ||
allowNull: false, | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
}, | ||
}); | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
await queryInterface.tableExists('OTP'); | ||
}, | ||
}; |
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,51 @@ | ||
import { Optional, UUIDV4 } from 'sequelize'; | ||
import { DataTypes, Model } from 'sequelize'; | ||
import sequelize from '.'; | ||
import User from './user'; | ||
|
||
export interface OtpAttributes { | ||
id: string; | ||
token: string; | ||
userId?: string; | ||
} | ||
|
||
export interface OtpCreationAttributes extends Optional<OtpAttributes, 'id'> {} | ||
|
||
class Otp extends Model<OtpAttributes, OtpCreationAttributes> implements OtpAttributes { | ||
public id!: string; | ||
public token!: string; | ||
public userId!: string | undefined; | ||
public readonly createdAt: Date | undefined; | ||
public readonly updatedAt: Date | undefined; | ||
} | ||
Otp.init( | ||
{ | ||
id: { | ||
type: DataTypes.UUID, | ||
defaultValue: UUIDV4, | ||
allowNull: false, | ||
unique: true, | ||
primaryKey: true, | ||
}, | ||
token: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
userId: { | ||
type: DataTypes.UUID, | ||
defaultValue: UUIDV4, | ||
references: { | ||
model: User, | ||
key: 'id', | ||
}, | ||
}, | ||
}, | ||
{ | ||
sequelize, | ||
timestamps: true, | ||
tableName: 'OTP', | ||
} | ||
); | ||
Otp.belongsTo(User, { foreignKey: 'userId' }); | ||
|
||
export default Otp; |
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
Oops, something went wrong.