• This project
    • Loading...
  • Sign in

fe / yohobuywap-node · Files

Go to a project

GitLab

  • Go to group
  • Project
  • Activity
  • Files
  • Commits
  • Pipelines 0
  • Builds 0
  • Graphs
  • Milestones
  • Issues 0
  • Merge Requests 0
  • Members
  • Labels
  • Wiki
  • Forks
  • Network
  • Create a new issue
  • yohobuywap-node
  • doraemon
  • middleware
  • auth.js
  • Merge remote-tracking branch 'origin/release/5.1' into release/5.1
    5743e166
    by 陈轩
    2016-10-21 13:43:05 +0800  
    Browse Files
auth.js 489 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/**
 * 登录判断
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2016/4/25
 */
'use strict';

const helpers = global.yoho.helpers;

module.exports = (req, res, next) => {
    if (!req.user.uid) {
        if (req.xhr) {
            return res.json({
                code: 400,
                message: '抱歉,您暂未登录!'
            });
        }

        return res.redirect(helpers.urlFormat('/signin.html', {
            refer: req.originalUrl
        }));
    }

    next();
};