2018-10-24

2018-10-24  本文已影响0人  恋兮兮
owner.login = function(loginInfo, callback) {callback = callback || $.noop;loginInfo = loginInfo || {};
        loginInfo.account = loginInfo.account || '';
        loginInfo.password = loginInfo.password || '';
        if (loginInfo.account.length < 5) {
            return callback('账号最短为 5 个字符');
        }
        if (loginInfo.password.length < 6) {
            return callback('密码最短为 6 个字符');
        }
        var users = JSON.parse(localStorage.getItem('$users') || '[]');
        var authed = users.some(function(user) {
            return loginInfo.account == user.account && loginInfo.password == user.password;
        });
        if (authed) {
            return owner.createState(loginInfo.account, callback);
        } else {
            return callback('用户名或密码错误');
        }
    };
owner.login = function(loginInfo, callback) {callback = callback || $.noop;loginInfo = loginInfo || {};
        loginInfo.account = loginInfo.account || '';
        loginInfo.password = loginInfo.password || '';
        if (loginInfo.account.length < 5) {
            return callback('账号最短为 5 个字符');
        }
        if (loginInfo.password.length < 6) {
            return callback('密码最短为 6 个字符');
        }
        var users = JSON.parse(localStorage.getItem('$users') || '[]');
        var authed = users.some(function(user) {
            return loginInfo.account == user.account && loginInfo.password == user.password;
        });
        if (authed) {
            return owner.createState(loginInfo.account, callback);
        } else {
            return callback('用户名或密码错误');
        }
    };
owner.login = function(loginInfo, callback) {callback = callback || $.noop;loginInfo = loginInfo || {};
        loginInfo.account = loginInfo.account || '';
        loginInfo.password = loginInfo.password || '';
        if (loginInfo.account.length < 5) {
            return callback('账号最短为 5 个字符');
        }
        if (loginInfo.password.length < 6) {
            return callback('密码最短为 6 个字符');
        }
        var users = JSON.parse(localStorage.getItem('$users') || '[]');
        var authed = users.some(function(user) {
            return loginInfo.account == user.account && loginInfo.password == user.password;
        });
        if (authed) {
            return owner.createState(loginInfo.account, callback);
        } else {
            return callback('用户名或密码错误');
        }
    };
上一篇下一篇

猜你喜欢

热点阅读