- if (body.password !== undefined) user.password = body.password
- if (body.email !== undefined) user.email = body.email
- if (body.nsfwPolicy !== undefined) user.nsfwPolicy = body.nsfwPolicy
- if (body.webTorrentEnabled !== undefined) user.webTorrentEnabled = body.webTorrentEnabled
- if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo
- if (body.videosHistoryEnabled !== undefined) user.videosHistoryEnabled = body.videosHistoryEnabled
+ const keysToUpdate: (keyof UserUpdateMe & keyof AttributesOnly<UserModel>)[] = [
+ 'password',
+ 'nsfwPolicy',
+ 'webTorrentEnabled',
+ 'autoPlayVideo',
+ 'autoPlayNextVideo',
+ 'autoPlayNextVideoPlaylist',
+ 'videosHistoryEnabled',
+ 'videoLanguages',
+ 'theme',
+ 'noInstanceConfigWarningModal',
+ 'noAccountSetupWarningModal',
+ 'noWelcomeModal'
+ ]
+
+ for (const key of keysToUpdate) {
+ if (body[key] !== undefined) user.set(key, body[key])
+ }
+
+ if (body.email !== undefined) {
+ if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) {
+ user.pendingEmail = body.email
+ sendVerificationEmail = true
+ } else {
+ user.email = body.email
+ }
+ }