Fix linting
This commit is contained in:
parent
553ba9db9a
commit
bb5189c9ed
35 changed files with 157 additions and 866 deletions
|
@ -20,7 +20,7 @@ function userAgentCheck(userAgent) {
|
|||
}
|
||||
|
||||
function referrerCheck(referrer) {
|
||||
return referrer && referrerRegexes.some((regex) => referrer.match(regex));
|
||||
return referrer && referrerRegexes.some(regex => referrer.match(regex));
|
||||
}
|
||||
|
||||
function hotlinkCheck(file, userAgent, referrer) {
|
||||
|
@ -52,7 +52,7 @@ export async function get(ctx) {
|
|||
}
|
||||
|
||||
if (file.malware) {
|
||||
const alert = ctx.request.query.alert;
|
||||
const { alert } = ctx.request.query;
|
||||
if (!alert || !alert.match(/i want to download malware/i)) {
|
||||
ctx.redirect(`/${file.id}`);
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import uuid from 'node-uuid';
|
||||
import auth from '../lib/auth';
|
||||
import { fromToken, fromCookie, setupSession } from '../lib/auth';
|
||||
|
||||
export async function main(ctx) {
|
||||
if (ctx.session.user) {
|
||||
|
@ -11,18 +11,16 @@ export async function main(ctx) {
|
|||
await ctx.redis.set(token, ctx.session.user.id, 'EX', 604800);
|
||||
ctx.session.user.token = token;
|
||||
await ctx.render('index', { user: ctx.session.user });
|
||||
} else if (ctx.query['app-token']) {
|
||||
const user = await fromToken(ctx, ctx.query['app-token']);
|
||||
await setupSession(ctx, user);
|
||||
ctx.redirect('/');
|
||||
} else if (ctx.cookies.r) {
|
||||
const user = await fromCookie(ctx, ctx.cookies.r);
|
||||
await setupSession(ctx, user);
|
||||
ctx.redirect('/');
|
||||
} else {
|
||||
if (ctx.query['app-token']) {
|
||||
const user = await auth.fromToken(ctx, ctx.query['app-token']);
|
||||
await auth.setupSession(ctx, user);
|
||||
ctx.redirect('/');
|
||||
} else if (ctx.cookies.r) {
|
||||
const user = await auth.fromCookie(ctx, ctx.cookies.r);
|
||||
await auth.setupSession(ctx, user);
|
||||
ctx.redirect('/');
|
||||
} else {
|
||||
await ctx.render('marketing');
|
||||
}
|
||||
await ctx.render('marketing');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import debugname from 'debug';
|
||||
import {
|
||||
authenticate, setupSession, signup as signupUser, activateUser, sendResetToken,
|
||||
validateResetToken, updatePassword,
|
||||
} from '../lib/auth';
|
||||
|
||||
import models from '../../models';
|
||||
import debugname from 'debug';
|
||||
|
||||
const debug = debugname('hostr-web:user');
|
||||
|
||||
export async function signin(ctx) {
|
||||
|
@ -44,17 +46,20 @@ export async function signup(ctx) {
|
|||
await ctx.render('signup', { error: 'Emails do not match.', csrf: ctx.csrf });
|
||||
return;
|
||||
} else if (ctx.request.body.email && !ctx.request.body.terms) {
|
||||
await ctx.render('signup', { error: 'You must agree to the terms of service.',
|
||||
csrf: ctx.csrf });
|
||||
await ctx.render('signup', {
|
||||
error: 'You must agree to the terms of service.',
|
||||
csrf: ctx.csrf,
|
||||
});
|
||||
return;
|
||||
} else if (ctx.request.body.password && ctx.request.body.password.length < 7) {
|
||||
await ctx.render('signup', { error: 'Password must be at least 7 characters long.',
|
||||
csrf: ctx.csrf });
|
||||
await ctx.render('signup', {
|
||||
error: 'Password must be at least 7 characters long.',
|
||||
csrf: ctx.csrf,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const ip = ctx.headers['x-forwarded-for'] || ctx.ip;
|
||||
const email = ctx.request.body.email;
|
||||
const password = ctx.request.body.password;
|
||||
const { email, password } = ctx.request.body;
|
||||
try {
|
||||
await signupUser.call(ctx, email, password, ip);
|
||||
} catch (e) {
|
||||
|
@ -66,12 +71,11 @@ export async function signup(ctx) {
|
|||
message: 'Thanks for signing up, we\'ve sent you an email to activate your account.',
|
||||
csrf: '',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
export async function forgot(ctx) {
|
||||
const token = ctx.params.token;
|
||||
const { token } = ctx.params;
|
||||
|
||||
if (ctx.request.body.password) {
|
||||
if (ctx.request.body.password.length < 7) {
|
||||
|
@ -87,7 +91,7 @@ export async function forgot(ctx) {
|
|||
if (user) {
|
||||
await updatePassword(user.userId, ctx.request.body.password);
|
||||
const reset = await models.reset.findById(token);
|
||||
//reset.destroy();
|
||||
reset.destroy();
|
||||
await setupSession.call(ctx, user);
|
||||
ctx.statsd.incr('auth.reset.success', 1);
|
||||
ctx.redirect('/');
|
||||
|
@ -104,11 +108,10 @@ export async function forgot(ctx) {
|
|||
return;
|
||||
}
|
||||
await ctx.render('forgot', { csrf: ctx.csrf, token });
|
||||
return;
|
||||
} else if (ctx.request.body.email) {
|
||||
ctx.assertCSRF(ctx.request.body);
|
||||
try {
|
||||
const email = ctx.request.body.email;
|
||||
const { email } = ctx.request.body;
|
||||
await sendResetToken.call(ctx, email);
|
||||
ctx.statsd.incr('auth.reset.request', 1);
|
||||
await ctx.render('forgot', {
|
||||
|
@ -136,7 +139,7 @@ export async function logout(ctx) {
|
|||
|
||||
|
||||
export async function activate(ctx) {
|
||||
const code = ctx.params.code;
|
||||
const { code } = ctx.params;
|
||||
if (await activateUser.call(ctx, code)) {
|
||||
ctx.statsd.incr('auth.activation', 1);
|
||||
ctx.redirect('/');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue