<commit_before>var express = require('express');
var router = express.Router();
var mysql = require('mysql');
var util = require('util');

var firebase = require('firebase');

var connection = mysql.createConnection({
    host: "localhost",
    user: "root",
    password: "<PASSWORD>",
    database: "pamperme"
}, 'request');

var client = false;
var babysitter = false;
const CLIENTS = "SELECT * from clients";
const BABYSITTER = "SELECT * from babysitter";
const USER = "SELECT * from clienttype where UID = '%s'";

var loggedUser;


firebase.auth().onAuthStateChanged(function (user) {
    if (user) {
        loggedUser = user;
        var name, email, photoUrl, uid, emailVerified;
        if (user != null) {
            name = user.displayName;
            email = user.email;
            photoUrl = user.photoURL;
            emailVerified = user.emailVerified;
            uid = user.uid;  // The user's ID, unique to the Firebase project. Do NOT use
                             // this value to authenticate with your backend server, if
                             // you have one. Use User.getToken() instead.
        }
    } else {
        loggedUser = null;
        client = false;
        babysitter = false;
    }
});


router.get('/', function (req, res) {
    if (loggedUser != null) {
        if (isBabysitter(loggedUser.uid, function (result) {
                if (result) {
                    babysitter = true;
                    res.render('index', {title: "PamperMe", babySitter: babysitter});
                }
            })) {
        } else if (isClient(loggedUser.uid, function (result) {
                if (result) {
                    client = true;
                    res.render('index', {title: "PamperMe", client: client});
                }
            })) {
        }else {
            //TODO First time signed in control
        }
    } else {
        res.render('index',{title: "PamperMe"});
    }
});


router.get('/login', function (req, res) {
    res.render('login');
});

router.get('/register', function (req, res) {
    res.render('register');
});

router.post('/register', function (req, res) {
    firebase.auth().createUserWithEmailAndPassword(req.body.email, req.body.password).then(function (data) {
        res.redirect('/');
    }).catch(function (error) {
        res.send(error);
    })

});

router.post('/login', function (req, res) {
    firebase.auth().signInWithEmailAndPassword(req.body.email, req.body.password).then(function (data) {
        res.redirect('/user');
    }).catch(function (error) {
        res.send(error);
    });
});
<commit_msg>select type of user automatically<commit_after>var express = require('express');
var router = express.Router();
var mysql = require('mysql');
var util = require('util');

var firebase = require('firebase');

var connection = mysql.createConnection({
    host: "localhost",
    user: "root",
    password: "<PASSWORD>",
    database: "pamperme"
}, 'request');

var client = false;
var babysitter = false;
const CLIENTS = "SELECT * from clients";
const BABYSITTER = "SELECT * from babysitter";
const USER = "SELECT * from clienttype where UID = '%s'";

var loggedUser;


firebase.auth().onAuthStateChanged(function (user) {
    if (user) {
        loggedUser = user;
        var name, email, photoUrl, uid, emailVerified;
        if (user != null) {
            name = user.displayName;
            email = user.email;
            photoUrl = user.photoURL;
            emailVerified = user.emailVerified;
            uid = user.uid;  // The user's ID, unique to the Firebase project. Do NOT use
                             // this value to authenticate with your backend server, if
                             // you have one. Use User.getToken() instead.
        }
    } else {
        loggedUser = null;
        client = false;
        babysitter = false;
    }
});


router.get('/', function (req, res) {
    if (loggedUser != null) {
        if (isBabysitter(loggedUser.uid, function (result) {
                if (result) {
                    babysitter = true;
                    res.render('index', {title: "PamperMe", babySitter: babysitter});
                }
            })) {
        } else if (isClient(loggedUser.uid, function (result) {
                if (result) {
                    client = true;
                    res.render('index', {title: "PamperMe", client: client});
                }
            })) {
        }else {
            //TODO First time signed in control
        }
    } else {
        res.render('index',{title: "PamperMe"});
    }
});


router.get('/login', function (req, res) {
    res.render('login');
});

router.get('/register', function (req, res) {
    res.render('register');
});

router.post('/register', function (req, res) {
    firebase.auth().createUserWithEmailAndPassword(req.body.email, req.body.password).then(function (data) {
        res.redirect('/');
    }).catch(function (error) {
        res.send(error);
    })

});

router.post('/login', function (req, res) {
    firebase.auth().signInWithEmailAndPassword(req.body.email, req.body.password).then(function (data) {
        res.redirect('/');
    }).catch(function (error) {
        res.send(error);
    });
});

{'fraction_non_alphanumeric': 0.14754098360655737, 'fraction_numerical': 0.0, 'mean_word_length': 2.140035906642729, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3167383', 'n_tokens_mistral': 1558, 'n_tokens_neox': 1521, 'n_words': 378}