api.js 637 Bytes
Newer Older
Rosanny Sihombing's avatar
Rosanny Sihombing committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// ==== 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()) {
            // read data based on ID
            dbconn.user.query('SELECT title, firstname, lastname, email, industry, organisation, speciality FROM user WHERE email="'+req.user.email+'"', function (err, rows, fields) {
                if (err) throw err
                res.send(rows[0])
            })
        } else {
Rosanny Sihombing's avatar
Rosanny Sihombing committed
16
          res.redirect('/account/');
Rosanny Sihombing's avatar
Rosanny Sihombing committed
17
18
19
20
        }
    });
    
}