const crypto = require('crypto'); const cheerio = require('cheerio'); const {defaultPermissions} = require('../util/default.json'); const Wiki = require('../util/wiki.js'); const allLangs = require('./i18n.js').allLangs().names; const {got, oauth, sessionData, settingsData, sendMsg, addWidgets, createNotice, hasPerm} = require('./util.js'); const file = require('fs').readFileSync('./dashboard/login.html'); /** * Let a user login * @param {import('http').ServerResponse} res - The server response * @param {import('./i18n.js')} dashboardLang - The user language. * @param {String} theme - The display theme * @param {String} [state] - The user state * @param {String} [action] - The action the user made */ function dashboard_login(res, dashboardLang, theme, state, action) { if ( state && sessionData.has(state) ) { if ( !action ) { res.writeHead(302, {Location: '/'}); return res.end(); } sessionData.delete(state); } var $ = cheerio.load(file); $('html').attr('lang', dashboardLang.lang); if ( theme === 'light' ) $('html').addClass('theme-light'); $('