What is contained into the variable 'user' 'session' at login from log_on_user function?

I’m currently building a plugin to create a custom cookie who is set up after a client login into the forum and destroyed after he logout. The plugin will be linked with this function :

 def log_on_user(user, session, cookies)
    unless user.auth_token && user.auth_token.length == 32
        user.auth_token = SecureRandom.hex(16)
    cookies.permanent[TOKEN_COOKIE] = { value: user.auth_token, httponly: true }
    @env[CURRENT_USER_KEY] = user

My question is what are the values of the variables :

  • user ?
  • session ?

Can i do user.username to get the username or user.username_lower ?

At least a need the username, the API can do the rest :slight_smile:


Or maybe i will have more change with the function after_authenticate(auth_token) from discourse/open_id_authenticator.rb at master · discourse/discourse · GitHub to get the username after login.