
var express        = require('express');
var router         = express.Router();
var userRoutes     = require('./user');
var sessionRoutes  = require('./session');
var homeRoutes     = require('./home');
var fashionRoutes  = require('./fashion');
var categoryRoutes = require('./category');
var roleRoutes     = require('./role');

function isLoggedIn(req, res, next) {
  if(req.isAuthenticated()){
    return next();
  }
  req.session.returnTo = req.path;
  res.redirect('/login');
}

function isAdmin(req, res, next) {
  if(req.isAuthenticated()){
    if(req.user.role == 'admin'){
      return next();
    }
  }
  req.session.returnTo = req.path;
  res.redirect('/login');
}

router.get('/', homeRoutes.index);

/*
 * @user routes
*/
router.get('/register',           userRoutes.new);
router.post('/signup',            userRoutes.create);

/*
 * @session routes 
*/
router.get('/login',           sessionRoutes.new);
router.post('/login',          sessionRoutes.create);
router.get('/logout',          sessionRoutes.delete);

/*
 * @session routes 
*/
router.get('/admin/index',        fashionRoutes.index);
router.get('/user/item',          fashionRoutes.single);
router.post('/admin/create',      fashionRoutes.add);
router.get('/admin/create',       fashionRoutes.new);
router.post('/admin/update',      fashionRoutes.update);
router.get('/admin/index/delete', fashionRoutes.delete);

/*
 * @category Routes
 */
router.get('/admin/categoty/new', categoryRoutes.new);
router.get('/admin/categoty',     categoryRoutes.get);
router.post('admin/category/add', categoryRoutes.add);

/*
 * @Role routes
 */
router.get('/admin/assign/:username/:role', roleRoutes.assign);
router.get('/admin/role/:role',             roleRoutes.create);
module.exports=router;

@@ -1025,32 +1025,31 @@
 e);%0A%0A/*%0A * @
-sess
+fash
 ion
- 
 routes %0A*/%0Ar
@@ -1066,21 +1066,24 @@
 '/admin/
-index
+fashions
 ',      
@@ -1162,35 +1162,34 @@
 single);%0Arouter.
-pos
+ge
 t('/admin/create
@@ -1210,19 +1210,19 @@
 nRoutes.
-add
+new
 );%0Aroute
@@ -1215,34 +1215,35 @@
 es.new);%0Arouter.
-ge
+pos
 t('/admin/create
@@ -1228,38 +1228,40 @@
 er.post('/admin/
-create
+fashions
 ',       fashion
@@ -1259,35 +1259,35 @@
   fashionRoutes.
-new
+add
 );%0Arouter.post('
@@ -1359,101 +1359,252 @@
 dex/
-delete', fashionRoutes.delete);%0A%0A/*%0A * @category Routes%0A */%0Arouter.get('/admin/categoty
+edit',   fashionRoutes.edit);%0Arouter.get('/admin/delete', fashionRoutes.delete);%0Arouter.post('/admin/another',      fashionRoutes.addsize);%0A%0A/*%0A * @category Routes%0A */%0Arouter.get('/admin/add', categoryRoutes.index);%0Arouter.get('/admin
 /new',
+    
  cat
@@ -1617,24 +1617,188 @@
 outes.new);%0A
+router.post('admin/add', categoryRoutes.add);%0A%0A/*%0A * @size Routes%0A */%0Arouter.get('/admin/another', sizeRoutes.index);%0Arouter.get('/admin/newer', sizeRoutes.new);%0A//
 router.get('
@@ -1857,37 +1857,29 @@
 st('
+/
 admin/
-category/add', category
+another', size
 Rout
@@ -1884,24 +1884,26 @@
 utes.add);%0A%0A
+%0A%0A
 /*%0A * @Role 

add fashion category and size routes