[READ-ONLY] Mirror of https://github.com/probablykasper/ferrum. Music library app for Mac, Linux and Windows ferrum.kasper.space
electron linux macos music music-library music-player napi windows
0

Configure Feed

Select the types of activity you want to include in your feed.

Revert "Registering uses elasticsearch"

This reverts commit 73ecdf5e6d0572de2c79b01831386a29103f3c20.

KH (Sep 26, 2017, 11:17 PM +0200) 398558d6 73ecdf5e

+26 -49
+24 -48
web/src/modules/routes.js
··· 220 220 // console.log("-----err"); 221 221 // console.log(error); 222 222 // }); 223 + // client.indices.putMapping({ 224 + // index: "users", 225 + // type: "cooltype", 226 + // body: { 227 + // "properties": { 228 + // "full_name": { 229 + // "type": "text" 230 + // } 231 + // } 232 + // } 233 + // }).then((body) => { 234 + // console.log("-----suc"); 235 + // console.log(body); 236 + // }, (error) => { 237 + // console.log("-----err"); 238 + // console.log(error); 239 + // }); 223 240 224 241 module.exports.register = (req, res) => { 225 242 let email = req.body.email; ··· 232 249 if (!validator.isLength(password, {min: 8})) errors.password = "short"; 233 250 if (!validator.isLength(password, {max: 100})) errors.password = "long"; 234 251 if (!validator.equals(password2, password)) errors.password2 = "match"; 235 - client.search({ 236 - index: "users", 237 - type: "user", 238 - q: "email:"+email, 239 - size: 1 240 - }).then((body) => { 241 - if (body.hits.total == 0) { 252 + db.query("SELECT * FROM users WHERE email = ?", email, function(err, result) { 253 + if (err) console.log(err); 254 + if (result[0] && result[0].email == email) errors.email = "exist"; 255 + if (result[1] && result[1].email == email) errors.email = "exist"; 256 + if (!errors.email && !errors.password && !errors.password2) { 242 257 bcrypt.genSalt(10, function(err, salt) { 243 258 if (err) { 244 259 jsonResErr(res, {unknown: 55529}); ··· 258 273 }).then((body) => { 259 274 jsonResErr(res, null); 260 275 }, (error) => { 261 - jsonResErr(res, {unknown: 50132}); 276 + jsonResErr(res, 29132); 262 277 }); 263 278 } 264 279 }); 265 280 } 266 281 }); 267 - } else if (body.hits.total == 1) { 268 - jsonResErr(res, {email: "exist"}); 269 - } else { 270 - jsonResErr(res, {unknown: 59283}); 271 - } 272 - 273 - }, (error) => { 274 - jsonResErr(res, {unknown: 52334}); 282 + } else res.json({ "errors": errors }); 275 283 }); 276 - // db.query("SELECT * FROM users WHERE email = ?", email, function(err, result) { 277 - // if (err) console.log(err); 278 - // if (result[0] && result[0].email == email) errors.email = "exist"; 279 - // if (result[1] && result[1].email == email) errors.email = "exist"; 280 - // if (!errors.email && !errors.password && !errors.password2) { 281 - // bcrypt.genSalt(10, function(err, salt) { 282 - // if (err) { 283 - // jsonResErr(res, {unknown: 55529}); 284 - // } else { 285 - // bcrypt.hash(password, salt, function(err, hashedPassword) { 286 - // if (err) { 287 - // jsonResErr(res, {unknown: 55222}); 288 - // } else { 289 - // client.index({ 290 - // index: "users", 291 - // type: "user", 292 - // body: { 293 - // userId: b32(6), 294 - // email: email, 295 - // password: hashedPassword 296 - // } 297 - // }).then((body) => { 298 - // jsonResErr(res, null); 299 - // }, (error) => { 300 - // jsonResErr(res, 29132); 301 - // }); 302 - // } 303 - // }); 304 - // } 305 - // }); 306 - // } else res.json({ "errors": errors }); 307 - // }); 308 284 }; 309 285 310 286 module.exports.logout = (req, res) => {
+2 -1
web/src/static/global.js
··· 1389 1389 if (!d) d = validate("noMatch", "The passwords do not match", password2, password ); 1390 1390 if (!a && !b && !c && !d) { 1391 1391 var req = 1392 - "email="+email.value+ 1392 + "type=register"+ 1393 + "&email="+email.value+ 1393 1394 "&password="+password.value+ 1394 1395 "&password2="+password2.value; 1395 1396