We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3fbdecd commit c798dc8Copy full SHA for c798dc8
1 file changed
common/models/user.js
@@ -1,13 +1,16 @@
1
-module.exports = function(user) {
+module.exports = function (user) {
2
3
- user.beforeCreate = function(next, user) {
4
- if (user.username == undefined) {
5
- user.username = user.email;
+ // Set the username to the users email address by default.
+ user.observe('before save', function setDefaultUsername(ctx, next) {
+ if (ctx.instance) {
6
+ if (ctx.instance.username === undefined) {
7
+ ctx.instance.username = ctx.instance.email;
8
+ }
9
+ ctx.instance.status = 'created';
10
+ ctx.instance.created = Date.now();
11
+ ctx.instance.confirmPassword = null;
12
}
- user.status = 'created';
- user.created = Date.now();
13
next();
- };
-
14
+ });
15
16
};
0 commit comments