[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.

Registering uses elasticsearch

KH (Sep 26, 2017, 9:20 PM +0200) 73ecdf5e 23795ed7

+49 -26
+48 -24
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 - // }); 240 223 241 224 module.exports.register = (req, res) => { 242 225 let email = req.body.email; ··· 249 232 if (!validator.isLength(password, {min: 8})) errors.password = "short"; 250 233 if (!validator.isLength(password, {max: 100})) errors.password = "long"; 251 234 if (!validator.equals(password2, password)) errors.password2 = "match"; 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) { 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) { 257 242 bcrypt.genSalt(10, function(err, salt) { 258 243 if (err) { 259 244 jsonResErr(res, {unknown: 55529}); ··· 273 258 }).then((body) => { 274 259 jsonResErr(res, null); 275 260 }, (error) => { 276 - jsonResErr(res, 29132); 261 + jsonResErr(res, {unknown: 50132}); 277 262 }); 278 263 } 279 264 }); 280 265 } 281 266 }); 282 - } else res.json({ "errors": errors }); 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}); 283 275 }); 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 + // }); 284 308 }; 285 309 286 310 module.exports.logout = (req, res) => {
+1 -2
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 - "type=register"+ 1393 - "&email="+email.value+ 1392 + "email="+email.value+ 1394 1393 "&password="+password.value+ 1395 1394 "&password2="+password2.value; 1396 1395