mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 13:20:41 +01:00
feat: utilities login API route now starts an actual login session, if requested
This commit is contained in:
@@ -15,9 +15,14 @@ post:
|
||||
username:
|
||||
type: string
|
||||
example: admin
|
||||
required: true
|
||||
password:
|
||||
type: string
|
||||
example: '123456'
|
||||
required: true
|
||||
session:
|
||||
type: number
|
||||
example: 1
|
||||
responses:
|
||||
'200':
|
||||
description: credentials successfully validated
|
||||
|
||||
@@ -23,7 +23,7 @@ Utilities.ping.post = (req, res) => {
|
||||
|
||||
Utilities.login = (req, res) => {
|
||||
res.locals.continueLogin = async (strategy, req, res) => {
|
||||
const { username, password } = req.body;
|
||||
const { username, password, session } = req.body;
|
||||
|
||||
const userslug = slugify(username);
|
||||
const uid = await user.getUidByUserslug(userslug);
|
||||
@@ -37,8 +37,13 @@ Utilities.login = (req, res) => {
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
const userData = await user.getUsers([uid], uid);
|
||||
helpers.formatApiResponse(200, res, userData.pop());
|
||||
const userData = (await user.getUsers([uid], uid)).pop();
|
||||
|
||||
if (parseInt(session, 10) === 1) {
|
||||
await authenticationController.doLogin(req, userData.uid);
|
||||
}
|
||||
|
||||
helpers.formatApiResponse(200, res, userData);
|
||||
} else {
|
||||
helpers.formatApiResponse(403, res);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user