Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CreateAccount(ws, data){
- let user=data.user;
- let pass=data.pass;
- function exists_cb(ws, err, res, data)
- {
- if (err || res.length>0)
- {
- let result={type:'register', state:false};
- ws.send(JSON.stringify(result));
- }
- else
- {
- function check_uuid(ws, uuid, err, res, data)
- {
- function create_cb(ws, err, res)
- {
- if (err)
- {
- let result={type:'register', state:false};
- ws.send(JSON.stringify(result));
- }
- else
- {
- result={type:'register', state:true};
- ws.send(ws.send(JSON.stringify(result)));
- }
- }
- if (err)
- {
- let result={type:'register', state:false};
- return;
- }
- if (res.length>0)
- {
- sql_conn.query("select * from accounts where valid='"+uid+"'", (err, res)=>check_uuid(ws, uuid() ,err, res));
- }
- else
- {
- sql_conn.query("INSERT INTO `accounts`(`username`, `password`, `valid`) VALUES ('"+data.user+"', '"+data.pass+"','"+uuid()+"')", (err, res)=>create_cb(ws, err, res));
- }
- }
- sql_conn.query("select * from accounts where valid='"+uid+"'", (err, res)=>check_uuid(ws, uuid(), err, res, data));
- }
- }
- sql_conn.query("select * from accounts where username='"+user+"' and password='"+pass+"'", (err, res)=>exists_cb(ws, err, res, data));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement