Skip to content

Commit

Permalink
Merge pull request #56 from KOSASIH/deepsource-transform-55e7c34e
Browse files Browse the repository at this point in the history
style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf
  • Loading branch information
KOSASIH authored May 10, 2024
2 parents f0b1218 + e7253c1 commit b737ab6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/models/user.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const mongoose = require("mongoose");
const bcrypt = require("bcrypt");
const mongoose = require('mongoose')
const bcrypt = require('bcrypt')

const UserSchema = new mongoose.Schema({
username: { type: String, required: true, unique: true },
password: { type: String, required: true },
});
password: { type: String, required: true }
})

UserSchema.pre("save", async function (next) {
if (this.isModified("password")) {
this.password = await bcrypt.hash(this.password, 10);
UserSchema.pre('save', async function (next) {
if (this.isModified('password')) {
this.password = await bcrypt.hash(this.password, 10)
}
next();
});
next()
})

UserSchema.methods.comparePassword = function (password) {
return bcrypt.compare(password, this.password);
};
return bcrypt.compare(password, this.password)
}

module.exports = mongoose.model("User", UserSchema);
module.exports = mongoose.model('User', UserSchema)

0 comments on commit b737ab6

Please sign in to comment.