                 data = salt: salt, slaveKey: encryptedSlaveKey
                 db.merge user._id, data, (err, res) =>
                     if err
-                        console.log "[Merge] err: #{err}"
+                        console.log "[initializeKeys] err: #{err}"
                         send 500
                     else
                         send 200

#PUT /account/:id
action 'updateAccount', ->
    @body = body
    encryptPassword (pwdExist) ->
        if pwdExist
            db.save params.id, @body, (err, res) ->
                if err
                    # oops unexpected error !
                    console.log "[Update] err: #{err}"
                    send 500
                else
                    send 200
        else
            send 401


#PUT /account/merge/:id
action 'mergeAccount', ->
    @body = body
    encryptPassword (pwdExist) ->
        db.merge params.id, @body, (err, res) ->
            if err
                # oops unexpected error !
                console.log "[Merge] err: #{err}"
                send 500
            else
                send 200


#PUT /account/upsert/:id
action 'upsertAccount', ->
    @body = body
    encryptPassword (pwdExist) ->
        if pwdExist
            db.get params.id, (err, doc) ->
                db.save params.id, body, (err, res) ->
                    if err

action 'initializeKeys', =>
    user.getUser (err, user) ->
        if err
            console.log "[initializeKeys] err: #{err}"
            send 500
        else
            app.crypto = {} if not app.crypto?
