Records of all logins

Hi there,

First of all, I want to thank this forum community which help me a lot to start using meteor when I was a total beginner. Now, I’m facing a problem that I can’t solve alone obviously. I’m trying to add a feature to an app that will record all logins (at least w/ username+timestamp, through a classic login form) in order to display all of them in a tab in our admin dashboard (ideally to be able to export it in a .xls file)

1/ So I’m wondering if there already is that kind of record, in meteor itself or in alanning:roles package, to retrieve those information.

2/ If not, I’ll probably create a “Activities” collection, with these allowedValues: [‘registration’, ‘login’, ‘deletion’, ‘profile_update’, ‘picture_update’, ‘post’, ‘like’, ‘comment’].
If you have any example of this kind of implementation, I’ll be reaally grateful!

Thx in advance!
++

There is no built-in logging.

There is however an undocumented feature to add login hooks on the server:

Accounts._validateLoginHook.register(login => {
  console.log(login)
  Log.insert({user_id:login.user._id, type:login.type, allowed:login.allowed})
  //Also, if you throw an Error here, the login will be denied
})
1 Like

Or the documented one :wink: (I’m sure it’s the exact same functionality though)

2 Likes

Oh right :smiley:
A bit confusing that it’s under multi-server