account-api.js 2.8 KB
/**
 * 个人中心---账户安全
 * @author gaohongwei <hongwei.gao@yoho.cn>
 * @date: 2016/8/30
 */
'use strict';

const api = global.yoho.API;

const getVerifyInfo = uid => {
    return api.get('', {
        method: 'web.passport.getUserVerifyInfo',
        uid: uid
    });

};

const checkEmailCode = code => {
    return api.get('', {
        method: 'web.passport.checkCodeValid',
        code: code
    });

};

const modifyVerifyEmail = code => {
    return api.get('', {
        method: 'web.passport.changeVerifyEmail',
        code: code
    });

};

const verifyPwd = (uid, password) => {
    return api.get('', {
        method: 'web.passport.verifyUserPwd',
        uid: uid,
        password: password
    });

};

const checkVerifyMsg = (area, mobile, code) => {
    return api.get('', {
        method: 'web.passport.checkcode',
        area: area,
        mobile: mobile,
        code: code
    });

};

/**
 * 邮箱身份验证--发送邮件
 * @param type $email
 * @param type $callback 成功后跳转链接
 * @return type
 */
const sendVerifyEmailForNext = (email, callback) => {
    return api.get('', {
        method: 'web.passport.sendVerifyEmailInfo',
        email: email,
        callback: callback
    });

};

/**
 * 修改验证手机号
 * @param type $uid
 * @param type $area
 * @param type $newMobile
 * @return type
 */
const modifyVerifyMobile = (uid, area, newMobile) => {
    return api.get('', {
        method: 'web.passport.modifyVerifyMobile',
        uid: uid,
        area: area,
        newMobile: newMobile
    });

};

/**
 * 修改邮箱前校验
 * @param type $uid
 * @param type $email
 */
const checkVerifyEmail = (uid, email) => {
    return api.get('', {
        method: 'web.passport.checkVerifyEmail',
        uid: uid,
        email: email
    });

};

/**
 * 验证邮箱--发送邮件
 * @param type $uid
 * @param type $email
 * @return type
 */
const sendVerifyEmail = (uid, email) => {
    return api.get('', {
        method: 'web.passport.verifyEmail',
        uid: uid,
        email: email
    });

};

 /**
 * 修改手机号前校验
 * @param type $mobile
 * @param type $area
 * @return type
 */
const checkVerifyMobile = (uid, mobile, area) => {
    return api.get('', {
        method: 'web.passport.checkVerifyMobile',
        uid: uid,
        mobile: mobile,
        area: area
    });

};

/**
 * 修改密码
 * @param type $uid
 * @param type $newPwd
 * @return type
 */
const modifyPwd = (uid, newPwd) => {
    return api.get('', {
        method: 'web.passport.changePwd',
        uid: uid,
        newPwd: newPwd
    });

};

module.exports = {
    getVerifyInfo,
    checkEmailCode,
    modifyVerifyEmail,
    verifyPwd,
    checkVerifyMsg,
    sendVerifyEmailForNext,
    checkVerifyEmail,
    checkVerifyMobile,
    sendVerifyEmail,
    modifyVerifyMobile,
    modifyPwd
};