-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
866bf24
commit c8dd198
Showing
7 changed files
with
146 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
var mysql = require('mysql'); | ||
|
||
var settings = require('./config'); | ||
var db; | ||
var exports = {}; | ||
exports.connectdb = function () { | ||
// if (!db){ | ||
db = mysql.createConnection(settings.Database); | ||
|
||
db.connect(function(err){ | ||
|
||
if(!err) { | ||
console.log('Database is connected!'); | ||
return db; | ||
} else { | ||
console.log('Error connecting database!'+err); | ||
return null; | ||
} | ||
}); | ||
// } | ||
} | ||
|
||
module.exports = exports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,76 @@ | ||
/** | ||
* Created by Shoaib on 11/05/2016. | ||
*/ | ||
// models/user.js | ||
// load the things we need | ||
var bcrypt = require('bcrypt-nodejs'); | ||
|
||
// define the schema for our user model | ||
var userSchema = { | ||
|
||
local : { | ||
email : String, | ||
password : String, | ||
}, | ||
facebook : { | ||
id : String, | ||
token : String, | ||
email : String, | ||
name : String | ||
}, | ||
twitter : { | ||
id : String, | ||
token : String, | ||
displayName : String, | ||
username : String | ||
}, | ||
google : { | ||
id : String, | ||
token : String, | ||
email : String, | ||
name : String | ||
} | ||
var exports = {}; | ||
|
||
var dbcon = require('../config/db.js'); | ||
var dbconn = dbcon.connectdb(); | ||
exports.login = function(email,password) { | ||
var userdetails = { name:email, password:password}; | ||
if ( dbconn == null ) console.log('still nul'); | ||
else console.log('not nul'); | ||
|
||
dbconn.query("SELECT * FROM users where email = '"+email+"' and password = '"+password +"'", function (err, result) { | ||
if(err) | ||
{ | ||
console.log(result[0]+' err'); | ||
return null; | ||
} | ||
else { | ||
console.log(result[0] + ' ress' ); | ||
console.log('query ok'); | ||
return result[0]; | ||
} | ||
// console.log('The solution is: ', result); // object difference result is same | ||
}); | ||
}; | ||
|
||
exports.fblogin = function(email,profileid) { | ||
|
||
var userdetails = { name:email, password:profileid}; | ||
dbconn.query("SELECT * FROM users where email = '"+email+"' and password = '"+password +"'", function (err, result) { | ||
if(err) | ||
{ | ||
console.log(result[0]+' err'); | ||
|
||
var userdetails = { name:email, password:profileid}; | ||
dbconn.query('INSERT INTO users SET ?', userdetails, function(err,res){ | ||
if(err) | ||
{console.log('err in insert fb'); | ||
} | ||
else { | ||
console.log('inserted fb'); | ||
|
||
} | ||
|
||
return null; | ||
}); | ||
} | ||
else { | ||
console.log(result[0] + ' ress' ); | ||
console.log('query ok'); | ||
} | ||
// console.log('The solution is: ', result); // object difference result is same | ||
}); | ||
}; | ||
exports.createuser = function(email,password){ | ||
|
||
if(dbconn ==null) | ||
console.log('null');else | ||
console.log('not null'); | ||
|
||
var userdetails = { name:email, password:password}; | ||
|
||
dbconn.query('INSERT INTO users SET ?', userdetails, function(err,res){ | ||
if(err) | ||
{ | ||
// throw err; | ||
return null; | ||
} | ||
else { | ||
|
||
console.log('Last insert ID:', res.insertId); | ||
return true; | ||
} | ||
}); | ||
|
||
}; | ||
|
||
// create the model for users and expose it to our app | ||
//module.exports = mongoose.model('User', userSchema); | ||
module.exports = userSchema; | ||
module.exports = exports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,21 +192,7 @@ function toggleMapPlanPanle() { | |
$(document).ready(function(){ | ||
initMap(); | ||
var lastSend = 0; | ||
$("#userLoginForm").submit(function(event) { | ||
/* | ||
@TODO: daniyal , Shoaib | ||
yaha pay login request handle ho gi | ||
*/ | ||
return false; | ||
var userLoginData= { | ||
Action: "Login", | ||
email: "[email protected]", | ||
password: "1234" | ||
}; | ||
socket.emit('login-user-request', userLoginData); | ||
|
||
event.preventDefault(); | ||
}); | ||
// local-login | ||
$("#send-message").submit(function(event) { | ||
if(pos==null) return false; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters