in src/server/services/cla.js [519:563]
async sign(args, item) {
if (!item) {
item = await this._getLinkedItem(args.repo, args.owner, args.token)
}
if (!item.gist) {
const nullClaErr = new Error('The repository doesn\'t need to sign a CLA because it has a null CLA.')
nullClaErr.code = 200
throw nullClaErr
}
const gist = await this._getGistObject(item.gist, item.token)
let onDates = [new Date()]
let currentVersion = gist.data.history[0].version
const cla = await this._getLastSignatureOnMultiDates(args.user, args.userId, item.repoId, item.orgId, item.sharedGist, item.gist, currentVersion, onDates)
if (cla) {
let signedErr = new Error('You\'ve already signed the cla')
signedErr.code = 200
throw signedErr
}
let argsToCreate = {
user: args.user,
userId: args.userId,
gist: item.gist,
gist_version: currentVersion,
custom_fields: args.custom_fields,
origin: args.origin,
created_at: args.created_at,
}
if (!item.sharedGist) {
argsToCreate.ownerId = item.orgId
argsToCreate.repoId = item.repoId
argsToCreate.org_cla = !!item.orgId
argsToCreate.owner = item.owner || item.org
argsToCreate.repo = item.repo
}
if (!argsToCreate.origin) {
logger.error(new Error('unknown origin of the signature'))
argsToCreate.origin = `unknown|${args.user}`
}
const signature = await this.create(argsToCreate)
return signature
}