diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-10 22:15:25 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-10 22:15:25 +0200 |
commit | 69818c9394366b954b6ba3bd697bd9d2b09f2a16 (patch) | |
tree | ad199a18ec3c322460d6f9523fc383ee562554e0 /server/models/user.ts | |
parent | 4d4e5cd4dca78480ec7f40e747f424cd107376a4 (diff) | |
download | PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.gz PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.zst PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.zip |
Type functions
Diffstat (limited to 'server/models/user.ts')
-rw-r--r-- | server/models/user.ts | 18 |
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 | ||
120 | function beforeCreateOrUpdate (user, options) { | 120 | function 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 | ||
134 | isPasswordMatch = function (password, callback) { | 134 | isPasswordMatch = 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 | ||
167 | countTotal = function (callback) { | 167 | countTotal = function (callback: UserMethods.CountTotalCallback) { |
168 | return this.count().asCallback(callback) | 168 | return this.count().asCallback(callback) |
169 | } | 169 | } |
170 | 170 | ||
171 | getByUsername = function (username) { | 171 | getByUsername = 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 | ||
181 | list = function (callback) { | 181 | list = function (callback: UserMethods.ListCallback) { |
182 | return User.find().asCallback(callback) | 182 | return User.find().asCallback(callback) |
183 | } | 183 | } |
184 | 184 | ||
185 | listForApi = function (start, count, sort, callback) { | 185 | listForApi = 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 | ||
199 | loadById = function (id, callback) { | 199 | loadById = function (id: number, callback: UserMethods.LoadByIdCallback) { |
200 | return User.findById(id).asCallback(callback) | 200 | return User.findById(id).asCallback(callback) |
201 | } | 201 | } |
202 | 202 | ||
203 | loadByUsername = function (username, callback) { | 203 | loadByUsername = 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 | ||
213 | loadByUsernameOrEmail = function (username, email, callback) { | 213 | loadByUsernameOrEmail = 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 } ] |