Skip to content

Commit 047a92c

Browse files
feat(auth): add public GET /api/auth/config endpoint
Expose auth feature flags (sign.in, sign.up) so the Vue frontend can display a warning when signin/signup is disabled server-side. Only boolean flags are returned — no secrets exposed.
1 parent 1254a08 commit 047a92c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

modules/auth/controllers/auth.controller.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,27 @@ const oauthCallback = async (req, res, next) => {
207207
})(req, res, next);
208208
};
209209

210+
/**
211+
* @desc Endpoint to expose public auth feature flags
212+
* @param {Object} req - Express request object
213+
* @param {Object} res - Express response object
214+
* @returns {Object} Public auth configuration (sign and oAuth flags only)
215+
*/
216+
const getConfig = (_req, res) => {
217+
responses.success(res, 'Auth config')({
218+
sign: {
219+
in: !!config.sign.in,
220+
up: !!config.sign.up,
221+
},
222+
});
223+
};
224+
210225
export default {
211226
signup,
212227
signin,
213228
token,
214229
oauthCall,
215230
oauthCallback,
216231
checkOAuthUserProfile,
232+
getConfig,
217233
};

modules/auth/routes/auth.routes.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import authPassword from '../controllers/auth.password.controller.js';
1313
export default (app) => {
1414
const authLimiter = rateLimit(config.rateLimit.auth);
1515

16+
// Public auth config (no authentication required, rate-limited)
17+
app.route('/api/auth/config').get(authLimiter, auth.getConfig);
18+
1619
// Setting up the users password api
1720
app.route('/api/auth/forgot').post(authLimiter, authPassword.forgot);
1821
app.route('/api/auth/reset/:token').get(authLimiter, authPassword.validateResetToken);

0 commit comments

Comments
 (0)