Skip to content

Commit

Permalink
Выбор отображения имени 4. При создании пользователя по дефолту disp …
Browse files Browse the repository at this point in the history
…принимаем за логин
  • Loading branch information
klimashkin committed Jul 24, 2013
1 parent a40c297 commit 02c6d2a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
21 changes: 8 additions & 13 deletions controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ function register(session, data, cb) {
if (!data.pass) error += 'Fill in the password field. ';
if (data.pass !== data.pass2) error += 'Passwords do not match.';
if (error) {
cb({message: error, error: true});
return;
return cb({message: error, error: true});
}

Step(
Expand All @@ -102,36 +101,33 @@ function register(session, data, cb) {
if (user.email === data.email) {
error += 'User with such email already exists.';
}
cb({message: error, error: true});
return;
return cb({message: error, error: true});
}
Counter.increment('user', this.parallel());
},
function createUser(err, count) {
if (err) {
cb({message: err, error: true});
return;
return cb({message: err, error: true});
}
if (!count) {
cb({message: 'Increment user counter error', error: true});
return;
return cb({message: 'Increment user counter error', error: true});
}
confirmKey = Utils.randomString(7);

var newUser = new User({
login: data.login,
cid: count.next,
email: data.email,
pass: data.pass
pass: data.pass,
disp: data.login
});

newUser.save(this.parallel());
UserConfirm.remove({user: newUser._id}, this.parallel());
},
function sendMail(err, user) {
if (err) {
cb({message: err.message, error: true});
return;
return cb({message: err.message, error: true});
}

new UserConfirm({key: confirmKey, user: user._id}).save(this.parallel());
Expand Down Expand Up @@ -162,8 +158,7 @@ function register(session, data, cb) {

function finish(err) {
if (err) {
cb({message: err.message, error: true});
return;
return cb({message: err.message, error: true});
}
cb({message: success});
}
Expand Down
2 changes: 2 additions & 0 deletions public/js/model/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ define(['jquery', 'underscore', 'knockout', 'knockout.mapping', 'Params'], funct
},
full: {
email: '',
firstName: '',
lastName: '',

//role
role: 0,
Expand Down
2 changes: 1 addition & 1 deletion public/js/module/common/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ define(['jquery', 'Utils', '../../socket', 'Params', 'knockout', 'm/_moduleClich

showPassChangeRecall: function (data, key, callback, ctx) {
this.login(data.login);
this.name(data.name);
this.name(data.disp);
this.avatar(data.avatar);
this.key(key);
this.show('passChangeRecall', callback, ctx);
Expand Down

0 comments on commit 02c6d2a

Please sign in to comment.