import { I18n } from '@ngx-translate/i18n-polyfill'
-import { Validators } from '@angular/forms'
+import { AbstractControl, ValidationErrors, Validators } from '@angular/forms'
import { Injectable } from '@angular/core'
import { BuildFormValidator } from '@app/shared'
constructor (private i18n: I18n) {
this.USERNAME = {
- VALIDATORS: [ Validators.required ],
+ VALIDATORS: [ Validators.required, this.localAccountValidator ],
MESSAGES: {
- 'required': this.i18n('The username is required.')
+ 'required': this.i18n('The username is required.'),
+ 'localAccountOnly': this.i18n('You can only transfer ownership to a local account')
}
}
}
+
+ localAccountValidator (control: AbstractControl): ValidationErrors {
+ if (control.value.includes('@')) {
+ return { 'localAccountOnly': true }
+ }
+
+ return null
+ }
}
if (isAble === false) {
res.status(403)
.json({ error: 'The user video quota is exceeded with this video.' })
- .end()
return cleanUpReqFiles(req)
}
logger.error('Invalid input file in videosAddValidator.', { err })
res.status(400)
.json({ error: 'Invalid input file.' })
- .end()
return cleanUpReqFiles(req)
}
cleanUpReqFiles(req)
return res.status(409)
.json({ error: 'Cannot set "private" a video that was not private.' })
- .end()
}
if (req.body.channelId && !await isVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req)
if (video.VideoChannel.Account.userId !== user.id && !user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)) {
return res.status(403)
.json({ error: 'Cannot get this private or blacklisted video.' })
- .end()
}
return next()
const nextOwner = await AccountModel.loadLocalByName(req.body.username)
if (!nextOwner) {
res.status(400)
- .type('json')
- .end()
+ .json({ error: 'Changing video ownership to a remote account is not supported yet' })
+
return
}
res.locals.nextOwner = nextOwner
} else {
res.status(403)
.json({ error: 'Ownership already accepted or refused' })
- .end()
+
return
}
}
if (isAble === false) {
res.status(403)
.json({ error: 'The user video quota is exceeded with this video.' })
- .end()
+
return
}
if (!req.body.scheduleUpdate.updateAt) {
res.status(400)
.json({ error: 'Schedule update at is mandatory.' })
- .end()
return true
}