Add a nextcloud compatible response for profile.
This commit is contained in:
parent
1e2bb83447
commit
80aace7b72
@ -2,15 +2,17 @@ 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) => {
|
export default Stacker(GetClientApiAuthMiddleware(), async (req: Request, res) => {
|
||||||
|
const mode = req.query.mode;
|
||||||
let mails = await Promise.all(
|
let mails = await Promise.all(
|
||||||
req.user.mails.map((id) => Mail.findById(id))
|
req.user.mails.map((id) => Mail.findById(id))
|
||||||
);
|
);
|
||||||
|
|
||||||
let mail = mails.find((e) => e.primary) || mails[0];
|
let mail = mails.find((e) => e.primary) || mails[0];
|
||||||
|
|
||||||
res.json({
|
let base_response = {
|
||||||
user_id: req.user.uid,
|
user_id: req.user.uid,
|
||||||
id: req.user.uid,
|
id: req.user.uid,
|
||||||
ID: req.user.uid,
|
ID: req.user.uid,
|
||||||
@ -19,5 +21,18 @@ export default Stacker(GetClientApiAuthMiddleware(), async (req: Request, res) =
|
|||||||
username: req.user.username,
|
username: req.user.username,
|
||||||
displayName: req.user.name,
|
displayName: req.user.name,
|
||||||
displayNameClaim: 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