Fix broken shit after dep updates
This commit is contained in:
parent
7878346910
commit
d89c8872d2
15 changed files with 1169 additions and 713 deletions
|
@ -23,7 +23,7 @@ export async function authenticate(email, password) {
|
|||
}
|
||||
const count = await models.login.count({
|
||||
where: {
|
||||
ip: remoteIp,
|
||||
ip: remoteIp.split(',')[0],
|
||||
successful: false,
|
||||
createdAt: {
|
||||
$gt: Math.ceil(Date.now()) - 600000,
|
||||
|
@ -43,7 +43,7 @@ export async function authenticate(email, password) {
|
|||
});
|
||||
|
||||
const login = await models.login.create({
|
||||
ip: remoteIp,
|
||||
ip: remoteIp.split(',')[0],
|
||||
successful: false,
|
||||
});
|
||||
|
||||
|
@ -65,6 +65,7 @@ export async function authenticate(email, password) {
|
|||
export async function setupSession(user) {
|
||||
debug('Setting up session');
|
||||
const token = uuid.v4();
|
||||
debug(user)
|
||||
await this.redis.set(token, user.id, 'EX', 604800);
|
||||
|
||||
const sessionUser = {
|
||||
|
|
|
@ -10,7 +10,7 @@ const debug = debugname('hostr-web:user');
|
|||
|
||||
export async function signin(ctx) {
|
||||
if (!ctx.request.body.email) {
|
||||
await ctx.render('signin', { csrf: ctx.csrf });
|
||||
await ctx.render('signin', { csrf: ctx.csrf, async: true });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -18,14 +18,15 @@ export async function signin(ctx) {
|
|||
|
||||
const user = await authenticate.call(ctx, ctx.request.body.email, ctx.request.body.password);
|
||||
|
||||
if (!user) {
|
||||
if (!user || !user.id) {
|
||||
ctx.statsd.incr('auth.failure', 1);
|
||||
await ctx.render('signin', { error: 'Invalid login details', csrf: ctx.csrf });
|
||||
await ctx.render('signin', { error: 'Invalid login details', csrf: ctx.csrf, async: true });
|
||||
return;
|
||||
} else if (user.activationCode) {
|
||||
await ctx.render('signin', {
|
||||
error: 'Your account hasn\'t been activated yet. Check for an activation email.',
|
||||
csrf: ctx.csrf,
|
||||
async: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -37,23 +38,25 @@ export async function signin(ctx) {
|
|||
|
||||
export async function signup(ctx) {
|
||||
if (!ctx.request.body.email) {
|
||||
await ctx.render('signup', { csrf: ctx.csrf });
|
||||
await ctx.render('signup', { csrf: ctx.csrf, async: true });
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx.request.body.email !== ctx.request.body.confirm_email) {
|
||||
await ctx.render('signup', { error: 'Emails do not match.', csrf: ctx.csrf });
|
||||
await ctx.render('signup', { error: 'Emails do not match.', csrf: ctx.csrf, async: true });
|
||||
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,
|
||||
async: true,
|
||||
});
|
||||
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,
|
||||
async: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -62,13 +65,14 @@ export async function signup(ctx) {
|
|||
try {
|
||||
await signupUser.call(ctx, email, password, ip);
|
||||
} catch (e) {
|
||||
await ctx.render('signup', { error: e.message, csrf: ctx.csrf });
|
||||
await ctx.render('signup', { error: e.message, csrf: ctx.csrf, async: true });
|
||||
return;
|
||||
}
|
||||
ctx.statsd.incr('auth.signup', 1);
|
||||
await ctx.render('signup', {
|
||||
message: 'Thanks for signing up, we\'ve sent you an email to activate your account.',
|
||||
csrf: ctx.csrf,
|
||||
async: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -82,6 +86,7 @@ export async function forgot(ctx) {
|
|||
error: 'Password needs to be at least 7 characters long.',
|
||||
csrf: ctx.csrf,
|
||||
token,
|
||||
async: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -103,10 +108,11 @@ export async function forgot(ctx) {
|
|||
error: 'Invalid password reset token. It might be expired, or has already been used.',
|
||||
csrf: ctx.csrf,
|
||||
token: null,
|
||||
async: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
await ctx.render('forgot', { csrf: ctx.csrf, token });
|
||||
await ctx.render('forgot', { csrf: ctx.csrf, token, async: true });
|
||||
} else if (ctx.request.body.email) {
|
||||
|
||||
try {
|
||||
|
@ -118,13 +124,14 @@ export async function forgot(ctx) {
|
|||
Be sure to check your spam folder if you it doesn't appear within a few minutes`,
|
||||
csrf: ctx.csrf,
|
||||
token: null,
|
||||
async: true,
|
||||
});
|
||||
return;
|
||||
} catch (error) {
|
||||
debug(error);
|
||||
}
|
||||
} else {
|
||||
await ctx.render('forgot', { csrf: ctx.csrf, token: null });
|
||||
await ctx.render('forgot', { csrf: ctx.csrf, token: null, async: true });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
</div>
|
||||
</section>
|
||||
|
||||
<% include footer.ejs %>
|
||||
<%- await include('footer') -%>
|
||||
<script>
|
||||
var mac = document.getElementById("mac");
|
||||
var windows = document.getElementById("windows");
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
</section>
|
||||
|
||||
|
||||
<% include footer.ejs %>
|
||||
<%- await include('footer') -%>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
</div>
|
||||
</section>
|
||||
|
||||
<% include footer.ejs %>
|
||||
<%- await include('footer') -%>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
</div>
|
||||
</section>
|
||||
|
||||
<% include footer.ejs %>
|
||||
<%- await include('footer') -%>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
</section>
|
||||
|
||||
|
||||
<% include footer.ejs %>
|
||||
<%- await include('footer') -%>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
</section>
|
||||
|
||||
|
||||
<% include footer.ejs %>
|
||||
<%- await include('footer') -%>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
</div>
|
||||
</section>
|
||||
|
||||
<% include footer.ejs %>
|
||||
<%- await include('footer') -%>
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue