Add a nextcloud compatible response for profile.
This commit is contained in:
parent
1e2bb83447
commit
80aace7b72
@ -1,23 +1,38 @@
|
|||||||
import Mail from "../../models/mail";
|
import Mail from "../../models/mail";
|
||||||
import { GetClientApiAuthMiddleware } from "../middlewares/client";
|
import { GetClientApiAuthMiddleware } from "../middlewares/client";
|
||||||
import Stacker from "../middlewares/stacker";
|
import Stacker from "../middlewares/stacker";
|
||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
|
import Logging from "@hibas123/nodelogging";
|
||||||
export default Stacker(GetClientApiAuthMiddleware(), async (req: Request, res) => {
|
|
||||||
let mails = await Promise.all(
|
export default Stacker(GetClientApiAuthMiddleware(), async (req: Request, res) => {
|
||||||
req.user.mails.map((id) => Mail.findById(id))
|
const mode = req.query.mode;
|
||||||
);
|
let mails = await Promise.all(
|
||||||
|
req.user.mails.map((id) => Mail.findById(id))
|
||||||
let mail = mails.find((e) => e.primary) || mails[0];
|
);
|
||||||
|
|
||||||
res.json({
|
let mail = mails.find((e) => e.primary) || mails[0];
|
||||||
user_id: req.user.uid,
|
|
||||||
id: req.user.uid,
|
let base_response = {
|
||||||
ID: req.user.uid,
|
user_id: req.user.uid,
|
||||||
sub: req.user.uid,
|
id: req.user.uid,
|
||||||
email: mail.mail,
|
ID: req.user.uid,
|
||||||
username: req.user.username,
|
sub: req.user.uid,
|
||||||
displayName: req.user.name,
|
email: mail.mail,
|
||||||
displayNameClaim: req.user.name,
|
username: req.user.username,
|
||||||
});
|
displayName: req.user.name,
|
||||||
})
|
displayNameClaim: req.user.name,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == "nextcloud") {
|
||||||
|
Logging.debug("Profile in Nextcloud mode");
|
||||||
|
base_response["ocs"] = {
|
||||||
|
data: {
|
||||||
|
id: base_response.user_id,
|
||||||
|
email: base_response.email,
|
||||||
|
"display-name": base_response.displayName,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json(base_response);
|
||||||
|
})
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hibas123/openauth",
|
"name": "@hibas123/openauth",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Loading…
Reference in New Issue
Block a user