Get linting passing again
This commit is contained in:
parent
4f95f27400
commit
494f66d388
21 changed files with 367 additions and 212 deletions
|
@ -15,12 +15,12 @@ export function* get() {
|
|||
export function* token() {
|
||||
const token = uuid.v4(); // eslint-disable-line no-shadow
|
||||
yield this.redis.set(token, this.user.id, 'EX', 86400);
|
||||
this.body = {token: token};
|
||||
this.body = { token };
|
||||
}
|
||||
|
||||
export function* transaction() {
|
||||
const Transactions = this.db.Transactions;
|
||||
const transactions = yield Transactions.find({'user_id': this.user.id}).toArray();
|
||||
const transactions = yield Transactions.find({ user_id: this.user.id }).toArray();
|
||||
|
||||
this.body = transactions.map((transaction) => { // eslint-disable-line no-shadow
|
||||
const type = transaction.paypal ? 'paypal' : 'direct';
|
||||
|
@ -29,17 +29,20 @@ export function* transaction() {
|
|||
amount: transaction.paypal ? transaction.amount : transaction.amount / 100,
|
||||
date: transaction.date,
|
||||
description: transaction.desc,
|
||||
type: type,
|
||||
type,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function* settings() {
|
||||
this.assert(this.request.body, 400, '{"error": {"message": "Current Password required to update account.", "code": 612}}');
|
||||
this.assert(this.request.body.current_password, 400, '{"error": {"message": "Current Password required to update account.", "code": 612}}');
|
||||
this.assert(this.request.body, 400,
|
||||
'{"error": {"message": "Current Password required to update account.", "code": 612}}');
|
||||
this.assert(this.request.body.current_password, 400,
|
||||
'{"error": {"message": "Current Password required to update account.", "code": 612}}');
|
||||
const Users = this.db.Users;
|
||||
const user = yield Users.findOne({'_id': this.user.id});
|
||||
this.assert(yield passwords.match(this.request.body.current_password, user.salted_password), 400, '{"error": {"message": "Incorrect password", "code": 606}}');
|
||||
const user = yield Users.findOne({ _id: this.user.id });
|
||||
this.assert(yield passwords.match(this.request.body.current_password, user.salted_password), 400,
|
||||
'{"error": {"message": "Incorrect password", "code": 606}}');
|
||||
const data = {};
|
||||
if (this.request.body.email && this.request.body.email !== user.email) {
|
||||
data.email = this.request.body.email;
|
||||
|
@ -48,10 +51,11 @@ export function* settings() {
|
|||
}
|
||||
}
|
||||
if (this.request.body.new_password) {
|
||||
this.assert(this.request.body.new_password.length >= 7, 400, '{"error": {"message": "Password must be 7 or more characters long.", "code": 606}}');
|
||||
data.salted_password = yield passwords.hash(this.request.body.new_password); // eslint-disable-line camelcase
|
||||
this.assert(this.request.body.new_password.length >= 7, 400,
|
||||
'{"error": {"message": "Password must be 7 or more characters long.", "code": 606}}');
|
||||
data.salted_password = yield passwords.hash(this.request.body.new_password);
|
||||
}
|
||||
Users.updateOne({_id: user._id}, {'$set': data});
|
||||
Users.updateOne({ _id: user._id }, { $set: data });
|
||||
this.body = {};
|
||||
}
|
||||
|
||||
|
@ -65,7 +69,7 @@ export function* events() {
|
|||
let json;
|
||||
try {
|
||||
json = JSON.parse(message);
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
debug('Invalid JSON for socket auth');
|
||||
this.websocket.send('Invalid authentication message. Bad JSON?');
|
||||
this.raven.captureError(err);
|
||||
|
@ -73,13 +77,13 @@ export function* events() {
|
|||
try {
|
||||
const reply = yield this.redis.get(json.authorization);
|
||||
if (reply) {
|
||||
pubsub.subscribe('/user/' + reply);
|
||||
pubsub.subscribe(`/user/${reply}`);
|
||||
this.websocket.send('{"status":"active"}');
|
||||
debug('Subscribed to: /user/%s', reply);
|
||||
} else {
|
||||
this.websocket.send('Invalid authentication token.');
|
||||
}
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
debug(err);
|
||||
this.raven.captureError(err);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue