Javascript Driver: how to login

Hi there

As documentation for the javascript driver is still lacking, perhaps someone could help me on the ladder to get started with it. I’ve already read client.jsx intensivly and even tried to understand the go example with no success.

If this little example could be completed, this could be a good starting point, written in coffeescript:

MyMatterMostClient = require 'mattermost'
##
## assuming environment variables are set 
##
mmHost = my.host.xx
mmURL = https://my.host.xx
mmUser = MATTERMOST_USER
mmPassword = SECRET_MATTERMOST_PASSWORD
mmGroup = MATTERMOST_TESTING_GROUP

##create the client

@myclient = new MyMatterMostClient.Client()

##give the variables

@myclient.setUrl(mmURL)
@myclient.useHeaderToken()
@myclient.enableLogErrorsToConsole(true)
@myclient.setTeamId(mmGroup)

##  now log in

@myclient.login(mmUser, mmPassword, null, mmsuccess, mmerror)

So far so good - but how to go further for instance to get all the teams the user belongs? There is a call “getAllTeams” but how to use it in this context?
Cheers
TG