mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-25 14:01:44 -04:00
feat(api-server): endpoint for classroom mode flag (#51708)
This commit is contained in:
committed by
GitHub
parent
dd05517242
commit
3ce08ba8aa
@@ -51,6 +51,7 @@ export default function settingsController(app) {
|
||||
);
|
||||
api.put('/update-my-honesty', ifNoUser401, updateMyHonesty);
|
||||
api.put('/update-my-quincy-email', ifNoUser401, updateMyQuincyEmail);
|
||||
api.put('/update-my-classroom-mode', ifNoUser401, updateMyClassroomMode);
|
||||
|
||||
app.use(api);
|
||||
}
|
||||
@@ -319,6 +320,17 @@ function updateMyQuincyEmail(...args) {
|
||||
)(...args);
|
||||
}
|
||||
|
||||
export function updateMyClassroomMode(...args) {
|
||||
const buildUpdate = body => _.pick(body, 'isClassroomAccount');
|
||||
const validate = ({ isClassroomAccount }) =>
|
||||
typeof isClassroomAccount === 'boolean';
|
||||
createUpdateUserProperties(
|
||||
buildUpdate,
|
||||
validate,
|
||||
'flash.classroom-mode-updated'
|
||||
)(...args);
|
||||
}
|
||||
|
||||
function handleInvalidUpdate(res) {
|
||||
res.status(403).json({
|
||||
type: 'danger',
|
||||
|
||||
Reference in New Issue
Block a user