diff --git a/index.js b/index.js index 1beb901..4bc32df 100644 --- a/index.js +++ b/index.js @@ -31,7 +31,7 @@ class Client { .catch(err => { throw new Error("Two Factor Unable to connect to Mongo"); }); - this.TwoFactorUser = mongoose.model("TwoFactorUser", userSchema); + this.TwoAuthUser = mongoose.model("two-auth-user", userSchema); this.create = mongooseCreate; this.send = mongooseSend; this.verify = mongooseVerify; diff --git a/mongoose/create.js b/mongoose/create.js index 1033603..069c52f 100644 --- a/mongoose/create.js +++ b/mongoose/create.js @@ -6,7 +6,7 @@ function create(userID, phone) { const client = this.client; const users = this.users; - const TwoFactorUser = this.TwoFactorUser; + const TwoAuthUser = this.TwoAuthUser; return new Promise((resolve, reject) => { if (typeof phone !== "string") { @@ -19,7 +19,7 @@ function create(userID, phone) { .create({ friendlyName: `Service for ${userID}` }) .then(service => { const { sid } = service; - TwoFactorUser.create({ + TwoAuthUser.create({ userID, sid, phone diff --git a/mongoose/send.js b/mongoose/send.js index 2d8c484..26f5bf0 100644 --- a/mongoose/send.js +++ b/mongoose/send.js @@ -5,9 +5,9 @@ function send(userID) { const users = this.users; const client = this.client; - const TwoFactorUser = this.TwoFactorUser; + const TwoAuthUser = this.TwoAuthUser; return new Promise((resolve, reject) => { - TwoFactorUser.findOne({ userID: userID }) + TwoAuthUser.findOne({ userID: userID }) .then(user => { const { sid, phone } = user; if (!sid) reject(new Error("SID Error: No SID exists for this user.")); diff --git a/mongoose/verify.js b/mongoose/verify.js index 3643d9a..a67bdbc 100644 --- a/mongoose/verify.js +++ b/mongoose/verify.js @@ -6,9 +6,9 @@ // status is true if verification succeeded, false if verification failed function verify(userID, code) { - const TwoFactorUser = this.TwoFactorUser; + const TwoAuthUser = this.TwoAuthUser; return new Promise((resolve, reject) => { - TwoFactorUser.findOne({ userID }) + TwoAuthUser.findOne({ userID }) .then(user => { const { sid, phone } = user; if (!sid) reject(new Error("SID Error: No SID exists for this user."));