Prosody: use the user nickname.

This commit is contained in:
John Livingston
2021-05-04 16:33:32 +02:00
parent deff34ab95
commit ad2d7742e9
3 changed files with 45 additions and 4 deletions

View File

@ -2,7 +2,7 @@ import type { Router, Request, Response, NextFunction } from 'express'
import { videoHasWebchat } from '../../../shared/lib/video'
import { asyncMiddleware } from '../middlewares/async'
import { prosodyCheckUserPassword, prosodyRegisterUser, prosodyUserRegistered } from '../prosody/auth'
import { getAuthUser } from '../helpers'
import { getAuthUser, getUserNickname } from '../helpers'
// See here for description: https://modules.prosody.im/mod_muc_http_defaults.html
interface RoomDefaults {
@ -92,10 +92,17 @@ async function initApiRouter (options: RegisterServerOptions): Promise<Router> {
res.sendStatus(403)
return
}
let userId: number | undefined
if (user.id) {
userId = parseInt(user.id)
if (Number.isNaN(userId)) { userId = undefined }
}
const password: string = await prosodyRegisterUser(user.username)
const nickname: string | undefined = userId ? (await getUserNickname(options, userId)) : undefined
res.status(200).json({
jid: user.username + '@localhost',
password: password
password: password,
nickname: nickname
})
}
))