-
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.
chg: added authentication middleware
- Loading branch information
1 parent
7d790f4
commit a5acb59
Showing
10 changed files
with
198 additions
and
85 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
76 changes: 40 additions & 36 deletions
76
seller/app/modules/authentication/models/organization.model.js
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,59 +1,63 @@ | ||
import mongoose from'mongoose'; | ||
import { uuid } from 'uuidv4'; | ||
|
||
import s3 from '../../../lib/utils/s3Utils' | ||
const organizationSchema = new mongoose.Schema({ //Users who has login ability should go under User schema | ||
_id:{ | ||
type: String, | ||
required:true, | ||
default: () => uuid(), | ||
}, | ||
name: { | ||
type: String, | ||
}, | ||
modules:[{ type: Object, ref: 'Model' }], | ||
welcomeScreenContent:{ | ||
type:String, | ||
}, | ||
shortCode: { | ||
type: String, | ||
required: true, | ||
}, | ||
isActive: { | ||
type: Boolean, | ||
}, | ||
profilePic:{ | ||
type:String, | ||
}, | ||
colors:{ | ||
pageBackGroundColor:{ | ||
type: String, | ||
}, | ||
iconButtonBackgroundColor: { | ||
type: String, | ||
}, | ||
iconColor:{ | ||
type: String, | ||
}, | ||
linkColor:{ | ||
type: String, | ||
}, | ||
formFieldBackgroundColor:{ | ||
type: String, | ||
}, | ||
}, | ||
name: {type:String,required:true}, | ||
address: {type:String}, | ||
contactEmail:{type:String}, | ||
contactMobile:{type:String}, | ||
addressProof:{type:String}, | ||
idProof:{type:String}, | ||
bankDetails:{ | ||
accHolderName:{type:String}, | ||
accNumber:{type:String}, | ||
IFSC:{type:String}, | ||
cancelledCheque:{type:String}, | ||
bankName:{type:String}, | ||
branchName:{type:String} | ||
}, | ||
PAN:{PAN:{type:String},proof:{type:String}}, | ||
GSTN:{GSTN:{type:String},proof:{type:String}}, | ||
FSSAI:{type:String}, | ||
createdAt:{ | ||
type:Number, | ||
default:Date.now() | ||
}, | ||
updatedAt:{ | ||
type:Number, | ||
default:Date.now() | ||
} | ||
}, | ||
createdBy:{type:String} | ||
},{ | ||
strict: true, | ||
timestamps:true | ||
}); | ||
|
||
organizationSchema.post('findOne',async function(doc, next) { | ||
if(doc){ | ||
let idProof = await s3.getSignedUrlForRead({path:doc.idProof}); | ||
doc.idProof =idProof | ||
|
||
let addressProof = await s3.getSignedUrlForRead({path:doc.addressProof}); | ||
doc.addressProof =addressProof | ||
|
||
let cancelledCheque = await s3.getSignedUrlForRead({path:doc.bankDetails.cancelledCheque}); | ||
doc.bankDetails.cancelledCheque =cancelledCheque | ||
|
||
let PAN = await s3.getSignedUrlForRead({path:doc.PAN.proof}); | ||
doc.PAN.proof =PAN | ||
|
||
let GSTN = await s3.getSignedUrlForRead({path:doc.GSTN.proof}); | ||
doc.GSTN.proof =GSTN | ||
} | ||
next(); | ||
}); | ||
|
||
organizationSchema.index({name:1,shortCode:1}, {unique: false}); | ||
const Organization = mongoose.model('Organization',organizationSchema); | ||
module.exports = Organization; |
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
Oops, something went wrong.