aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/user.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/user.ts')
-rw-r--r--server/models/user.ts18
1 files changed, 9 insertions, 9 deletions
diff --git a/server/models/user.ts b/server/models/user.ts
index 12ddaaeb7..0fbfdda50 100644
--- a/server/models/user.ts
+++ b/server/models/user.ts
@@ -117,7 +117,7 @@ export default function (sequelize, DataTypes) {
117 return User 117 return User
118} 118}
119 119
120function beforeCreateOrUpdate (user, options) { 120function beforeCreateOrUpdate (user: UserInstance) {
121 return new Promise(function (resolve, reject) { 121 return new Promise(function (resolve, reject) {
122 cryptPassword(user.password, function (err, hash) { 122 cryptPassword(user.password, function (err, hash) {
123 if (err) return reject(err) 123 if (err) return reject(err)
@@ -131,7 +131,7 @@ function beforeCreateOrUpdate (user, options) {
131 131
132// ------------------------------ METHODS ------------------------------ 132// ------------------------------ METHODS ------------------------------
133 133
134isPasswordMatch = function (password, callback) { 134isPasswordMatch = function (password: string, callback: UserMethods.IsPasswordMatchCallback) {
135 return comparePassword(password, this.password, callback) 135 return comparePassword(password, this.password, callback)
136} 136}
137 137
@@ -164,11 +164,11 @@ function associate (models) {
164 }) 164 })
165} 165}
166 166
167countTotal = function (callback) { 167countTotal = function (callback: UserMethods.CountTotalCallback) {
168 return this.count().asCallback(callback) 168 return this.count().asCallback(callback)
169} 169}
170 170
171getByUsername = function (username) { 171getByUsername = function (username: string) {
172 const query = { 172 const query = {
173 where: { 173 where: {
174 username: username 174 username: username
@@ -178,11 +178,11 @@ getByUsername = function (username) {
178 return User.findOne(query) 178 return User.findOne(query)
179} 179}
180 180
181list = function (callback) { 181list = function (callback: UserMethods.ListCallback) {
182 return User.find().asCallback(callback) 182 return User.find().asCallback(callback)
183} 183}
184 184
185listForApi = function (start, count, sort, callback) { 185listForApi = function (start: number, count: number, sort: string, callback: UserMethods.ListForApiCallback) {
186 const query = { 186 const query = {
187 offset: start, 187 offset: start,
188 limit: count, 188 limit: count,
@@ -196,11 +196,11 @@ listForApi = function (start, count, sort, callback) {
196 }) 196 })
197} 197}
198 198
199loadById = function (id, callback) { 199loadById = function (id: number, callback: UserMethods.LoadByIdCallback) {
200 return User.findById(id).asCallback(callback) 200 return User.findById(id).asCallback(callback)
201} 201}
202 202
203loadByUsername = function (username, callback) { 203loadByUsername = function (username: string, callback: UserMethods.LoadByUsernameCallback) {
204 const query = { 204 const query = {
205 where: { 205 where: {
206 username: username 206 username: username
@@ -210,7 +210,7 @@ loadByUsername = function (username, callback) {
210 return User.findOne(query).asCallback(callback) 210 return User.findOne(query).asCallback(callback)
211} 211}
212 212
213loadByUsernameOrEmail = function (username, email, callback) { 213loadByUsernameOrEmail = function (username: string, email: string, callback: UserMethods.LoadByUsernameOrEmailCallback) {
214 const query = { 214 const query = {
215 where: { 215 where: {
216 $or: [ { username }, { email } ] 216 $or: [ { username }, { email } ]