Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getRequestInfo () {
let request = this.prepareRequest(this.request)
// If we won't stick the following header laravel will
// process the request as usual and won't give any info.
request.headers.push({key: 'X-Api-Tester', value: 'route-info'})
// Modifies path if wheres are declared in request.
// Otherwise, we'll send to unmodified path.
let path = request.url
if (request.wheres) {
let wheres = request.wheres
for (let index in wheres) {
let mocker = new RandExp(new RegExp(wheres[index]))
let dummy = new RegExp('{' + index + '}', 'g')
path = path.replace(dummy, mocker.gen())
}
}
// Do sending.
this.$api.ajax(request.method, path, request.data, request.headers)
.then((response) => {
this.setRequestInfo(response.data)
this.setInfoError(false)
})
.catch(xhr => this.setInfoError(xhr.status))
},
send (request){
case 'name':
if (this.previousFirstName.length > 0) {
username = this.sanitizeName(this.previousFirstName);
}
if (this.previousLastName.length > 0) {
if (username.length > 0) {
username += `.${this.sanitizeName(this.previousLastName)}`;
} else {
username = this.sanitizeName(this.previousLastName);
}
}
break;
case 'regex':
try {
username = new RandExp(emailSettings.usernameRegEx).gen();
} catch (ex) {
// Do nothing.
}
break;
default:
break;
}
if (!username || username.length === 0) {
username = this.generateScrambledWord(4, 10).toLowerCase();
}
let domain = '';
if (emailSettings.hostname === 'list') {
)
if (!correct) {
ctx.throw(400, 'INVALID_CREDENTIALS')
}
} catch (error) {
console.log('here', error)
ctx.throw(400, 'INVALID_DATA')
}
//Let's get rid of that password now for security reasons
delete userData.password
//Generate the refreshToken data
let refreshTokenData = {
username: userData.username,
refreshToken: new rand(/[a-zA-Z0-9_-]{64,64}/).gen(),
info:
ctx.userAgent.os +
' ' +
ctx.userAgent.platform +
' ' +
ctx.userAgent.browser,
ipAddress: ctx.request.ip,
expiration: dateAddMonths(new Date(), 1),
isValid: true,
}
//Insert the refresh data into the db
try {
await db('refresh_tokens').insert(refreshTokenData)
} catch (error) {
ctx.throw(400, 'INVALID_DATA')
return function(engine) {
const regexp = new RegExp(s);
const randexp = new RandExp(regexp);
randexp.randInt = (from, to) => {
return Random.integer(from, to)(engine);
};
return randexp.gen();
}
},
async generateUniqueToken() {
let token = new rand(/[a-zA-Z0-9_-]{7,7}/).gen()
if (await this.checkUniqueToken(token)) {
await this.generateUniqueToken()
} else {
return token
}
}
async forgot(ctx) {
const request = ctx.request.body
if (!request.email || !request.url || !request.type) {
ctx.throw(404, 'INVALID_DATA')
}
let resetData = {
passwordResetToken: new rand(/[a-zA-Z0-9_-]{64,64}/).gen(),
passwordResetExpiration: dateAddMinutes(new Date(), 30),
}
try {
var result = await db('users')
.update(resetData)
.where({ email: request.email })
.returning('id')
if (!result) {
ctx.throw(400, 'INVALID_DATA')
}
} catch (error) {
ctx.throw(400, 'INVALID_DATA')
}
//Now for the email if they've chosen the web type of forgot password
randexp(regex: RegExp): RandExp {
const randExp = new RandExp(regex);
randExp.max = 10;
return randExp;
},
mongoObjectId(): string {
return this.generateNumber(field.min, field.max);
case 'date':
return moment(this.generateDate()).format(field.template);
case 'url':
return this.generateWebsite();
case 'text':
return this.generateParagraph(field.min, field.max, element.maxLength);
case 'alphanumeric':
return this.generateAlphanumeric(field.template);
case 'regex':
return new RandExp(field.template, field.caseInSensitive ? 'i' : '').gen();
case 'randomized-list':
return field.list[this.generateNumber(0, field.list.length - 1)];
default:
return this.generatePhrase(element.maxLength);
}
}