Skip to content

Add phone to serverpod_user_info table #729

Closed as not planned
Closed as not planned

Description

@wstrange

Minor feature request, but one that I think would be nice to have:

Many auth providers like firebase provide a phone number on authentication. If provided, it would be nice to store this in UserInfo.

It can be an optional, nullable field, and would not be a breaking change. Happy to provide a PR for firebase if you think it is a good idea.

Activity

  1. hortigado commented on Mar 13, 2023

    @hortigado

    Friend it exist. you can modify the user class

    class: UserServer
    table: users
    fields:
      uid: String
      name: String
      email: String
      photo: String
      phone: String?
    
  2. wstrange commented on Mar 13, 2023

    @wstrange
    ContributorAuthor

    @hortigado If I understand your comment, you are suggesting creating my own custom class? I can't see that table in the server_pod docs or the source code.

    If you are suggesting adding my own custom class - that is what I've done.

    The ask is really around including more of the standard OIDC / user info parameters provided by the auth provider (e.g. firebase) as out of the box features in the UserInfo class. I can add my own custom class for this - but then I have to link it with the UserInfo class. All quite possible - but not as convenient. Unless I am missing what you are suggesting.

    Perhaps a better solution is to allow the UserInfo class to be generated/extended by the developer? But then you'd have to integrate that with the auth modules...

    This isn't a show stopper - more of a paper cut - which is why it's a feature request (not a bug..)

  3. added
    enhancement
    on Mar 20, 2023
  4. vlidholt commented on Mar 20, 2023

    @vlidholt
    Collaborator

    I think this could be a useful addition, especially for implementing 2fa.

  5. tgrushka commented on May 13, 2023

    @tgrushka
    Contributor

    Is serverpod_user_info meant to be developer customizable or reference-able?

    That would be great, as every app will want to customize the user table fields. Would be nice to have standard way/docs to create our own User class that can extend serverpod's UserInfo. And of course the ability to use that User class in all auth methods/endpoints/backend functions. (Possibly an extends: UserInfo line in the protocol yaml?)

    I'm trying to do the following, and can't, because serverpod generate gives the following error (yes, I did add tables_serverpod_auth.pgsql -- as renamed -- to my project, and the tables do exist in my Postgres DB):

    class: Playlist
    table: playlist
    fields:
      userId: int, parent=serverpod_user_info

    serverpod generate
    ...
    FormatException: The table "playlist" (class "Playlist" is referencing a table that doesn't exist (serverpod_user_info).)

    BTW, it is also added to my my_server/config/generator.yaml and all of my pubspec.yamls:

    modules:
      serverpod_auth:
        nickname: auth
  6. tgrushka commented on May 13, 2023

    @tgrushka
    Contributor

    And I'm thinking adding this playlist_serverpod_user_info_fk.pgsql might work, but perhaps a bit cumbersome:

    ALTER TABLE ONLY "playlist"
      ADD CONSTRAINT playlist_serverpod_user_info_fk
        FOREIGN KEY("userId")
          REFERENCES serverpod_user_info(id)
            ON DELETE CASCADE;
  7. tgrushka commented on May 14, 2023

    @tgrushka
    Contributor

    Knew I had seen this earlier looking through serverpod code, but had to dig for it again. Deserves a doc addition, maybe I'll do a PR.

    This is related to this topic because of frequent need to reference the user info in apps.

    To get this to work (reference the user_info table as well as the UserInfo serializable model), it seems I do not need to add an extraClasses entry in generator.yaml. But since serverpod_auth has nickname: auth, specifying the "fully qualified" class as module:auth:UserInfo? as follows in the protocol generated a protocol file that included the serverpod_auth_server module and compiled properly:

    class: Favorite
    table: favorite
    fields:
      userId: int # FK defined in user_info_favorite.pgsql
      user: module:auth:UserInfo?, api
    ...
  8. tgrushka commented on May 14, 2023

    @tgrushka
    Contributor
  9. edzzn commented on Jun 17, 2024

    @edzzn

    Oh, found it: https://docs.serverpod.dev/concepts/modules#referencing-a-module

    I was looking for this, I think that the documentation can be more explicit about doing this. This is very common.

  10. added
    area: authentication
    on Dec 17, 2024
  11. marcelomendoncasoares commented on Apr 3, 2026

    @marcelomendoncasoares
    Collaborator

    With the new Firebase provider, you receive the optional phone data through the callback, which allows to store the data in a custom class that has a relation to the AuthUser. Since the recommended pattern is to extend the UserProfile through relations, I'll close this one as not planned.

  12. moved this from Backlog 🗂️ to Done 🚀 in Serverpod Frameworkson Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: authenticationenhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions