u
This commit is contained in:
@@ -7,9 +7,38 @@ import { meJson } from '../../auth/meJson.js';
|
||||
*/
|
||||
export function register(app, basePath = '') {
|
||||
/**
|
||||
* @route GET /auth/me
|
||||
* @description Returns the authenticated user from `req.user` and the Google client ID.
|
||||
* @returns {Object} 200 - `{ user: { id, email, selectedCompanyId, picture? }, googleClientId }`
|
||||
* @openapi
|
||||
* /auth/me:
|
||||
* get:
|
||||
* tags: [Auth]
|
||||
* summary: Current user
|
||||
* description: Returns the authenticated user from the session cookie and the Google client ID. Unauthenticated calls still receive `googleClientId` with 401.
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* x-markdown: auth/me.md
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Authenticated
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* user:
|
||||
* $ref: '#/components/schemas/User'
|
||||
* googleClientId:
|
||||
* type: string
|
||||
* 401:
|
||||
* description: Unauthorized — still includes `googleClientId` for the frontend
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* error:
|
||||
* type: string
|
||||
* googleClientId:
|
||||
* type: string
|
||||
*/
|
||||
app.get(`${basePath}/auth/me`, (req, res) => {
|
||||
const { id, email, selectedCompanyId, picture } = req.user;
|
||||
|
||||
Reference in New Issue
Block a user