3447b2e0e6
* Fixed a bunch of style bugs for chrome browsers * Improved check box styles on desktop and mobile * Touch up tool tip styles. Only dark now. * Created a separate terms page * Added 2FA auth token options to login * Added tool tip displays to some buttons on editor * Added pinned and archived options to overflow menu * Changed shared note styles * Disabled Scroll into view * Made image display smaller when adding images to notes * Added a last used color option * Updated help page * Fixed spelling error on terms page * Added a big ass green label on the new note icon * Scratch pad now opens a note, which is the scratch pad * Added better 2fa guide * Added change password option * Added log out and log out all active sessions option * Added strict rate limiting on login and register actions * Added middleware to routes that force authentication to be accessed * Fixed bug that was causing shared notes to appear empty * Updated option now appears on shared notes after they are actually updated
59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
var express = require('express')
|
|
var router = express.Router()
|
|
|
|
let Tags = require('@models/Tag')
|
|
|
|
let userId = null
|
|
let masterKey = null
|
|
|
|
// middleware that is specific to this router
|
|
router.use(function setUserId (req, res, next) {
|
|
|
|
//Session key is required to continue
|
|
if(!req.headers.sessionId){
|
|
next('Unauthorized')
|
|
}
|
|
|
|
if(req.headers.userId){
|
|
userId = req.headers.userId
|
|
masterKey = req.headers.masterKey
|
|
next()
|
|
}
|
|
})
|
|
|
|
//Get the latest notes the user has created
|
|
router.post('/suggest', function (req, res) {
|
|
Tags.suggest(userId, req.body.noteId, req.body.tagText)
|
|
.then( data => res.send(data) )
|
|
})
|
|
|
|
//Get latest tags based on when it was put on a note
|
|
router.post('/latest', function (req, res) {
|
|
Tags.latest(userId, req.body.noteId)
|
|
.then( data => res.send(data) )
|
|
})
|
|
|
|
//Get the latest notes the user has created
|
|
router.post('/addtonote', function (req, res) {
|
|
Tags.addToNote(userId, req.body.noteId, req.body.tagText.toLowerCase())
|
|
.then( data => res.send(data) )
|
|
})
|
|
|
|
router.post('/removefromnote', function (req, res) {
|
|
Tags.removeTagFromNote(userId, req.body.tagId)
|
|
.then( data => res.send(data) )
|
|
})
|
|
|
|
//Get the latest notes the user has created
|
|
router.post('/get', function (req, res) {
|
|
Tags.get(userId, req.body.noteId)
|
|
.then( data => res.send(data) )
|
|
})
|
|
|
|
//Get all the tags for this user in order of usage
|
|
router.post('/usertags', function (req, res) {
|
|
Tags.userTags(userId, req.body.searchQuery, req.body.searchTags, req.body.fastFilters)
|
|
.then( data => res.send(data) )
|
|
})
|
|
|
|
module.exports = router |