Add new profile endpoint
Add some logging output for auth failures
This commit is contained in:
23
Backend/src/api/oauth/profile.ts
Normal file
23
Backend/src/api/oauth/profile.ts
Normal file
@ -0,0 +1,23 @@
|
||||
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,
|
||||
});
|
||||
})
|
Reference in New Issue
Block a user