Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preconditions in a service (Socket.IO) #48

Closed
kwakayama opened this issue Apr 2, 2014 · 2 comments · Fixed by #50
Closed

Preconditions in a service (Socket.IO) #48

kwakayama opened this issue Apr 2, 2014 · 2 comments · Fixed by #50
Milestone

Comments

@kwakayama
Copy link

Hi,
I implemented the REST authentication mentioned in #43 .
Now I want the same for the Socket.IO communication.
A user can use the find and get service but for create, update and delete he has to be logged in. Is there a way with feathersjs to implement that?

@daffl
Copy link
Member

daffl commented Apr 2, 2014

Good timing, we're just discussing filtering SocketIO events in #44 for 0.4.0 that will be released soon. It will probably look like this:

var TodoService = {
    remove: function(id, params, callback) {

    },

    update: function(id, data, params, callback) {

    },

    create: function(data, params, callback) {

    },

    removed: function(data, params, callback) {
        // e.g. restrict by data company id
        if(params.user.companyId !== data.companyId) {
            return callback(null, false);
        }

        callback(null, data);
    },

    updated: function(data, params, callback) {
        // restrict by data company id
        if(params.user.companyId !== data.companyId) {
            return callback(null, false);
        }

        // This will also allow to convert the data sent
        callback(null, { converted: data });
    },

    created: function(data, params, callback) {
        // TODO implement
    }
}

Where the created, updated and removed params will be the handshake data set during SocketIO authorization. The trickier part I think is a plugin that does shared authorization between Express and SocketIO also existing methods like this one should already work.

@daffl daffl added this to the 0.4.0 milestone Apr 2, 2014
@daffl daffl closed this as completed in #50 Apr 8, 2014
daffl pushed a commit that referenced this issue Aug 21, 2018
BREAKING CHANGE: This module no longer supports Node.js 0.10
daffl pushed a commit that referenced this issue Aug 22, 2018
BREAKING CHANGE: This module no longer supports Node.js 0.10
daffl added a commit that referenced this issue Aug 25, 2018
Use AST transformations to import generated services and hooks
@lock
Copy link

lock bot commented Feb 8, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants