login-new.js 1.86 KB
const _ = require('lodash');

// const passport = require('passport');
// const uuid = require('uuid');
// const co = Promise.coroutine;
// const cookie = global.yoho.cookie;
// const helpers = global.yoho.helpers;
// const log = global.yoho.logger;
// const config = global.yoho.config;
// const cache = global.yoho.cache;
// const utils = require(global.utils);
// const RegService = require('../models/reg-service');
// const AuthHelper = require('../models/auth-helper');

// const resources = {
//     yohobuy: '',
//     yohomars: '',
//     yohocoffee: ''
// };

class Login {
    /**
     * 登录页面
     */
    loginPage(req, res) {
        // 是否关闭账号登录
        let closePassword = _.get(req.app.locals.wap, 'close.passwordLogin', false);

        if (closePassword) {
            return res.redirect(`/signin.html?refer=${req.query.refer || ''}`);
        }
        if (req.session.captchaValidCount == null) { // eslint-disable-line
            req.session.captchaValidCount = 5;
        }
        res.render('login/login-new', {
            module: 'passport',
            page: 'login-new',
            width750: true,
            captchaShow: req.yoho.captchaShow,
        });
    }

    /**
     * 国际账号登录
     */
    international(req, res) {
        // 是否关闭账号登录
        let closePassword = _.get(req.app.locals.wap, 'close.passwordLogin', false);

        if (closePassword) {
            return res.redirect(`/signin.html?refer=${req.query.refer || ''}`);
        }
        if (req.session.captchaValidCount == null) { // eslint-disable-line
            req.session.captchaValidCount = 5;
        }

        res.render('login/international-new', {
            module: 'passport',
            page: 'international-new',
            width750: true,
            captchaShow: req.yoho.captchaShow,
        });
    }
}

module.exports = Login;