<commit_before>var express = require('express')
var requireAll = require('./lib/require-all')
var authorization = require('express-authorization')
var passport = require('passport')
var utils = require("./lib/utils")
var BasicStrategy = require("passport-http").BasicStrategy
var User = require("./app/models/user")
var GatewayAccount = require("./app/models/gateway_account")

passport.use(new BasicStrategy(
  function(username, password, done) {
    User.find({ where: { name: username }}).complete(function (err, user) {
      if (err) { return done(err) }
      if (!user) { return done(null, false) }
      if (!utils.verifyPassword(password, user.salt, user.passwordHash)) { return done(null, false) }
      return done(null, user)
    })
  }
))

ctrls = requireAll({
  dirname: __dirname + '/app/controllers',
  filter: /(.+)\.js(on)?$/
})

var app = express()
app.use(express.static(__dirname + '/public'))
app.use(passport.initialize())

require('./config/initializers/middleware.js').configure(app)
//require('./config/routes').configure(app, ctrls)

app.get('/authenticated/resource', authorization.ensureRequest.isPermitted("user:view"), function(req, res){
  res.send({ success: 'access granted' })
})

app.get('/auth', function(req, res){
  req.session.user = { permissions: ['user:basic'] }
  res.send({ success: true })
})
app.get('/admin/confirm', 
  passport.authenticate('basic', { session: false }),
  function(req, res) {
    if (req.user.admin) {
      res.json({ success: true })
    } else {
      res.json({ success: false })
    }
  })

app.get('/api/v1/gateway/accounts/:id', 
  passport.authenticate('basic', { session: false }), function(req,res){
    GatewayAccount.find(req.params.id).complete(function(err, account){
      if (err) { res.send({ success: false }); return false }
      res.send({ success: true, gatewayAccount: account })<commit_msg>[CHORE] Remove unused routes, add route to vefify user.<commit_after>var express = require('express')
var requireAll = require('./lib/require-all')
var authorization = require('express-authorization')
var passport = require('passport')
var utils = require("./lib/utils")
var BasicStrategy = require("passport-http").BasicStrategy
var User = require("./app/models/user")
var GatewayAccount = require("./app/models/gateway_account")

passport.use(new BasicStrategy(
  function(username, password, done) {
    User.find({ where: { name: username }}).complete(function (err, user) {
      if (err) { return done(err) }
      if (!user) { return done(null, false) }
      if (!utils.verifyPassword(password, user.salt, user.passwordHash)) { return done(null, false) }
      return done(null, user)
    })
  }
))

ctrls = requireAll({
  dirname: __dirname + '/app/controllers',
  filter: /(.+)\.js(on)?$/
})

var app = express()
app.use(express.static(__dirname + '/public'))
app.use(passport.initialize())

require('./config/initializers/middleware.js').configure(app)

app.post('/gateway/users/verify', 
  passport.authenticate('basic', { session: false }),
  function(req, res) {
    if (req.user) {
      res.json({ success: true, user: user })
    } else {
      res.json({ success: false })
    }
  })

app.get('/api/v1/gateway/accounts/:id', 
  passport.authenticate('basic', { session: false }), function(req,res){
    GatewayAccount.find(req.params.id).complete(function(err, account){
      if (err) { res.send({ success: false }); return false }
      res.send({ success: true, gatewayAccount: account })
{'fraction_non_alphanumeric': 0.17960469779432828, 'fraction_numerical': 0.0005729017473503294, 'mean_word_length': 4.243243243243243, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4275914', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1090, 'n_words': 235}