Prosody: use the user nickname.
This commit is contained in:
@ -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
|
||||
})
|
||||
}
|
||||
))
|
||||
|
Reference in New Issue
Block a user