SolidScribe/server/routes/user.js
Max G b0a8071b41 Searching, url indexing
* Added a help page
* Cleaned up home and login pages
* Menu is hidden when on notes section of app
* Added username to login data
* Notes now change to the color selected for the note
* Note save function has a 500ms debounce to prevent spamming
* Solr results now displays content from notes, tags and attachments
* All note data is now indexed in solr
* Notes containing URLs are now scraped and put into tag solr index
* Attachments that are removed from note are deleted when url is removed
* Minor little tweaks and fixes all over the place
2019-07-24 18:06:50 +00:00

49 lines
1.0 KiB
JavaScript

var express = require('express')
var router = express.Router()
let User = require('@models/Users');
// middleware that is specific to this router
router.use(function timeLog (req, res, next) {
// console.log('Time: ', Date.now())
next()
})
// define the home page route
router.get('/', function (req, res) {
res.send('User Home Page ' + User.getUsername())
})
// define the about route
router.get('/about', function (req, res) {
User.getUsername(req.headers.userId)
.then( data => res.send(data) )
})
// define the login route
router.post('/login', function (req, res) {
//Pull out variables we want
const username = req.body.username
const password = req.body.password
let returnData = {
success: false,
token: '',
username: ''
}
User.login(username, password)
.then(function(loginToken){
//Return json web token to user
returnData['success'] = true
returnData['token'] = loginToken
returnData['username'] = username
res.send(returnData)
})
.catch(e => {
console.log(e)
res.send(returnData)
})
})
module.exports = router