UNPKG

@lcap/asl

Version:

NetEase Application Specific Language

39 lines 1.36 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const config_1 = __importDefault(require("./config")); const axios_1 = __importDefault(require("axios")); /** * 便捷登录,只支持普通登录 * @required 需要先配置好 config.baseURL * @param username 用户名 * @param password 密码 */ async function login(username, password) { const hostname = config_1.default.baseURL.split('/')[2]; const parts = hostname.split('.'); const res = await axios_1.default({ baseURL: config_1.default.baseURL, params: { Action: 'Login', Version: '2020-06-01' }, method: 'POST', url: '/proxy/nuims/gateway/nuims/nuims', data: { DomainName: 'low-code', LoginType: 'Normal', TenantName: parts[0], UserName: username, Password: password, }, headers: { Env: 'online', 'Content-Type': 'application/json;charset=UTF-8', }, withCredentials: false }); config_1.default.cookie = 'authorization=' + res.headers.authorization; return res.data && res.data.Data; } exports.default = login; //# sourceMappingURL=login.js.map