1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-10-08 19:45:15 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

initial commit

This commit is contained in:
sunnylqm
2020-02-19 00:18:43 +08:00
parent db7ad264da
commit d46cb5b46a
22 changed files with 6759 additions and 0 deletions

43
src/user.js Normal file
View File

@@ -0,0 +1,43 @@
/**
* Created by tdzl2003 on 2/13/16.
*/
import {question} from './utils';
const {
post,
get,
replaceSession,
saveSession,
closeSession,
} = require('./api');
const crypto = require('crypto');
function md5(str) {
return crypto.createHash('md5').update(str).digest('hex');
}
exports.commands = {
login: async function ({args}){
const email = args[0] || await question('email:');
const pwd = args[1] || await question('password:', true);
const {token, info} = await post('/user/login', {
email,
pwd: md5(pwd),
});
replaceSession({token});
await saveSession();
console.log(`Welcome, ${info.name}.`);
},
logout: async function (){
await closeSession();
console.log('Logged out.');
},
me: async function (){
const me = await get('/user/me');
for (const k in me) {
if (k !== 'ok') {
console.log(`${k}: ${me[k]}`);
}
}
},
}