Browse Source

Fixed small bug with auth, where email and username params were wrong way around

theflametrooper 8 years ago
parent
commit
c7963b4f1b
2 changed files with 5 additions and 6 deletions
  1. 4 5
      backend/logic/actions/users.js
  2. 1 1
      frontend/App.vue

+ 4 - 5
backend/logic/actions/users.js

@@ -78,7 +78,7 @@ module.exports = {
 				let json = JSON.parse(body);
 				console.log(json);
 				//if (json.success !== true) return next('Response from recaptcha was not successful');
-				db.models.user.findOne({ 'username': username }, next);
+				db.models.user.findOne({ username }, next);
 			},
 
 			// if the user already exists, respond with that
@@ -103,7 +103,7 @@ module.exports = {
 			// save the new user to the database
 			(hash, next) => {
 				db.models.user.create({
-					username: username,
+					username,
 					email: {
 						address: email,
 						verificationToken: utils.generateRandomString(64)
@@ -144,10 +144,9 @@ module.exports = {
 	},
 
 	findByUsername: (session, username, cb) => {
-		console.log(username)
 		db.models.user.find({ username }, (err, account) => {
-			if (account == [] && err) {
-				console.error(err);
+			if (err) throw err;
+			else if (account.length == 0) {
 				return cb({
 					status: 'error',
 					message: 'Username cannot be found'

+ 1 - 1
frontend/App.vue

@@ -42,7 +42,7 @@
 		events: {
 			'register': function () {
 				let { register: { email, username, password } } = this;
-				this.socket.emit('users.register', email, username, password, grecaptcha.getResponse(), (result) => {
+				this.socket.emit('users.register', username, email, password, grecaptcha.getResponse(), (result) => {
 					// Need to somehow execute this on Home.vue
 					// Toast.methods.addToast(`User ${username} has been registered`, 2000);
 					setTimeout(location.reload(), 2500);