sealcode / sealious

An extensible, declarative node framework
25 stars 2 forks source link

Creating user with email #243

Closed modliszka closed 8 years ago

modliszka commented 8 years ago

I figured out that if I want create resource user with field email we have to implement overloading (?) of function create_user in user_manager.js My proposition is to add (almost the same function as create_user but with parameter email):

this.create_user = function(context, username, password, email){
    var user_data;
    return Sealious.Dispatcher.users.user_exists(context, username)
        .then(function(user_exists){
            if (!user_exists) {
                Sealious.Logger.info("User " + username + " has been created");
                return Sealious.Dispatcher.resources.create(context, "user", {
                    username: username,
                    password: password,
                    email: email
                });
            } else {
                throw new Sealious.Errors.ValueExists("Username `" + username + "` is already taken.");
            }
        })
}

What do you think about it? Is it good or should I find solution somewhere else? (I've heard that you are going to remove this file ;> )

kuba-orlik commented 8 years ago

Hi, It looks like this is going to work. I suspect that you're using a fork of channel-www-server. If that's the case, apply the change you suggested to your fork - and when Sealious will support this kind of functionality natively, you'll just have to migrate back to the official version.

Any changes that we're currently working on will not land on 0.6, so in order to take advantage of them you'd have to rewrite some of your code anyway :)

BTW I'm closing this issue, as the changes you're suggesting are best kept in the fork that you're (I think!) using. If you need any further assistance with this issue, please use our mailing list or email me directly :)