UNPKG

@batlify/mscms2-api

Version:

MineStoreCMS v3 API package

34 lines (33 loc) 1.16 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const context_1 = __importDefault(require("../../../core/context")); class AuthClassic extends context_1.default { /* * Login user * @note Authorization isn't needed (obviously, it's login) * @param username User's username * @returns banned | success | failed * @throws Error */ async login(username) { try { const response = await this.request(false, 'POST', '/auth/username', { username }); if (response === 'banned') { return { status: 'banned' }; } if (response && typeof response === 'string') { this.setCookie('mscms_auth_token', response); this.setCookie('mscms_auth_username', username); return { status: 'success' }; } return { status: 'failed' }; } catch (e) { throw e; } } } exports.default = AuthClassic;