api_TBD.js 582 Bytes
Newer Older
Rosanny Sihombing's avatar
Rosanny Sihombing committed
1
2
3
4
5
6
7
8
9
// ==== USER ACOOUNT API ====
var dbconn = require('./dbconn')
module.exports = function (app) {

    //console.log(dbconn);
    //var con = dbconn.connection
    
    app.get('/api/v1/profile', function (req, res) {
        if (req.isAuthenticated()) {
Wolfgang Knopki's avatar
Wolfgang Knopki committed
10
11
            // read data based on email
            dbconn.user.query('SELECT * FROM user WHERE email="'+req.user.email+'"', function (err, rows, fields) {
Rosanny Sihombing's avatar
Rosanny Sihombing committed
12
13
14
15
                if (err) throw err
                res.send(rows[0])
            })
        } else {
Wolfgang Knopki's avatar
Wolfgang Knopki committed
16
          res.send('authentication required');
Rosanny Sihombing's avatar
Rosanny Sihombing committed
17
18
19
20
        }
    });
    
}