mirror of
https://github.com/Foltik/Shimapan
synced 2025-01-07 08:42:49 -05:00
Fix auth code
This commit is contained in:
parent
fac4dfe5f6
commit
e01051f97f
@ -3,8 +3,8 @@ var path = require('path');
|
|||||||
|
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
var router = express.Router();
|
var router = express.Router();
|
||||||
|
var async = require('async');
|
||||||
|
|
||||||
var mongoose = require('mongoose');
|
|
||||||
var User = require('../models/User.js');
|
var User = require('../models/User.js');
|
||||||
var Invite = require('../models/Invite.js');
|
var Invite = require('../models/Invite.js');
|
||||||
|
|
||||||
@ -37,26 +37,26 @@ router.post('/register', function(req, res) {
|
|||||||
// Validate the parameters
|
// Validate the parameters
|
||||||
async.parallel({
|
async.parallel({
|
||||||
username: function(callback) {
|
username: function(callback) {
|
||||||
checkUsername(function(err, valid) {
|
checkUsername(req.body.username, function(err, valid) {
|
||||||
callback(err, valid);
|
callback(err, valid);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
invite: function(callback) {
|
invite: function(callback) {
|
||||||
checkInvite(function(err, valid, invite) {
|
checkInvite(req.body.invite, function(err, valid, invite) {
|
||||||
callback(err, {valid: valid, invite: invite});
|
callback(err, {valid: valid, invite: invite});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, function(err, res) {
|
}, function(err, result) {
|
||||||
if (!res.username) {
|
if (!result.username) {
|
||||||
res.status(401).json({'message': 'Username in use.'});
|
res.status(401).json({'message': 'Username in use.'});
|
||||||
} else if (!res.invite.valid) {
|
} else if (!result.invite.valid) {
|
||||||
res.status(401).json({'message': 'Invalid invite code.'});
|
res.status(401).json({'message': 'Invalid invite code.'});
|
||||||
} else {
|
} else {
|
||||||
useInvite(req.body.invite);
|
useInvite(req.body.invite, req.body.username);
|
||||||
|
|
||||||
var user = new User();
|
var user = new User();
|
||||||
user.username = req.body.username;
|
user.username = req.body.username;
|
||||||
user.scope = res.invite.scope;
|
user.scope = result.invite.scope;
|
||||||
user.date = new Date();
|
user.date = new Date();
|
||||||
user.setPassword(req.body.password);
|
user.setPassword(req.body.password);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user