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

USER: auth and identification. #1

Open
4 of 10 tasks
seitbekir opened this issue Sep 9, 2017 · 0 comments
Open
4 of 10 tasks

USER: auth and identification. #1

seitbekir opened this issue Sep 9, 2017 · 0 comments

Comments

@seitbekir
Copy link
Owner

seitbekir commented Sep 9, 2017

After connection user might be identified. Auth logic have to be in special function, that fires after connect and reconnect. User data has to be stored in connection.

User may be identified by an ID, and working with user has to be encapsulated.

user auth:

app.user('user-connected', connection => {
    // connection is socket connection instance
    // connection.data contains queried creds
    let data = connection.data
    if ('id' in data) {
        db.findUserById(data.id)
            .then(res => {
                connection.setUser(data.id, res)
                // Client got message, that connection is allowed
                connection.allow()
            })
            .catch(err => {
                // Client got message, that connection is denied by server
                connection.deny({
                    message: 'this ID not allowed to be authorized'
                })
            })
    }
})

Roadmap

  • Support token getting
  • Support user events
  • Create User prototype
  • Support user object to keep connections
  • Make User class to work with connection
  • Add events support
    • first-connected
    • new-connected
    • last-connected
    • user-disconnected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant