title: Where and how to change session user object after signing in?
body: <p>I have weird problem and I don't know where the problem is. I use <a href="https://next-auth.js.org/" rel="noreferrer">next-auth</a> library to make authentication system in my <code>Next.js</code> app.</p>
  <p>Everything is OK - I can sign in by checking if there is account in <code>google firebase</code> with submitted credentials, <code>session</code> is being created properly, but when the <code>authorize</code> callback is initialized I pass data received from <code>google firestore</code> after correct sign in. User object contains whole data and it's passed forward.</p>
  <p>Then, when I want to read data from <code>session</code>, some data I passed before is missing.</p>
  <p>Code:</p>
  <p>/pages/api/auth/[...nextauth.js]</p>
  <pre class="lang-js prettyprint-override"><code>export default (req, res) =&gt; 
      NextAuth(req, res, {
          providers: [
              Providers.Credentials({
                  name: 'Credentials',
                  credentials: {
                      phone: { label: &quot;Phone number&quot;, type: &quot;text&quot; },
                      password: { label: &quot;Password&quot;, type: &quot;password&quot; }
                  },
                  authorize: async (loginData) =&gt; {
                      const { csrfToken, phone, password } = loginData;
                      
                      //  checking if there is account with these credentials
                      let res = await login({
                          phone, 
                          password: sha1(md5(password)).toString()
                      })
  
                      //  200 = OK
                      if(res.status == 200){
                          //  collect account data
                          const user = {
                              phone,
                              ...res.data.info
                          }
  
                          //  user object is created correctly, whole data is stored there
                          console.log('received account data from firestore', user)
                          return Promise.resolve(user);
                      }
                      else {
                          //  wrong credentials
                          return Promise.resolve(null);
                      }
                  }
              })
          ],
          callbacks: {
              session: async (session, user) =&gt; {
                  console.log('data passed to object when signed in', user)
                  //  user object there doesn't have all data passed before
                  return Promise.resolve(session)
              }
          },
          debug: false
      })
  </code></pre>
  <p>Console logged objects:</p>
  <pre><code>received account data from firestore 
  {
    phone: '123123123',
    id: 'w2zh88BZzSv5BJeXZeZX',
    email: 'jan@gmail.com',
    name: 'Jan',
    surname: 'Kowalski'
  }
  </code></pre>
  <pre><code>data passed to object when signed in 
  {
    name: 'Jan',
    email: 'jan@gmail.com',
    iat: 1603900133,
    exp: 1606492133
  }
  </code></pre>
  <p>The best thing is, the object (above) always has the same properties. I can pass any object in <code>authorize</code> callback, but in <code>session</code>, <code>user</code> object always has &quot;name, email, iat, exp&quot; ALWAYS. The only thing that changes are values of these two properties in object (name, email). (rest properties - &quot;phone, id, surname&quot; - are missing).</p>
  <p>Below there is console logged <code>session</code> object in any react component:</p>
  <pre><code>import {
      signIn, 
      signOut,
      useSession
  } from 'next-auth/client'
  
  const [ session, loading ] = useSession();
  console.log(session)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/KbhO9.png" rel="noreferrer">Photo of console logged session object</a></p>
  <p>What can I do? Do I have to receive data from <code>firestore</code> separately in <code>session</code> callback? Is the server-side rendering of <code>Next.js</code> causing the problem?</p>