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 { GetClientApiAuthMiddleware } from "../middlewares/client";
|
||||
import Stacker from "../middlewares/stacker";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export default Stacker(GetClientApiAuthMiddleware(), async (req: Request, res) => {
|
||||
let mails = await Promise.all(
|
||||
req.user.mails.map((id) => Mail.findById(id))
|
||||
);
|
||||
|
||||
let mail = mails.find((e) => e.primary) || mails[0];
|
||||
|
||||
res.json({
|
||||
user_id: req.user.uid,
|
||||
id: req.user.uid,
|
||||
ID: req.user.uid,
|
||||
sub: req.user.uid,
|
||||
email: mail.mail,
|
||||
username: req.user.username,
|
||||
displayName: req.user.name,
|
||||
displayNameClaim: req.user.name,
|
||||
});
|
||||
})
|
||||
import Mail from "../../models/mail";
|
||||
import { GetClientApiAuthMiddleware } from "../middlewares/client";
|
||||
import Stacker from "../middlewares/stacker";
|
||||
import { Request, Response } from "express";
|
||||
import Logging from "@hibas123/nodelogging";
|
||||
|
||||
export default Stacker(GetClientApiAuthMiddleware(), async (req: Request, res) => {
|
||||
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];
|
||||
|
||||
let base_response = {
|
||||
user_id: req.user.uid,
|
||||
id: req.user.uid,
|
||||
ID: req.user.uid,
|
||||
sub: req.user.uid,
|
||||
email: mail.mail,
|
||||
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",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
Loading…
Reference in New Issue
Block a user