FreedomBen / libmalan

Simple TypeScript utility methods for accessing the Malan authentication service
MIT License
0 stars 1 forks source link

missing user attributes #21

Open crcommons opened 2 years ago

crcommons commented 2 years ago

Malan accepts a variety of user attributes, but we're not making them available in libmalan. Let's map them over here.

FreedomBen commented 2 years ago

@crcommons Here's the whole "full' user object (there's also an "abbreviated" one that omits addresses and phone numbers but "full" is the default). I tried to add a non-null type for all of them but might have missed some:

{
  "data": {
    "addresses": [
      {   
        "city": "some city",
        "country": "some country",
        "id": "f6992c51-4070-4cb3-80f1-cab905c7e2e3",
        "line_1": "l1",
        "line_2": "l2",
        "name": "Jared",
        "postal": "po",
        "primary": false,
        "state": "ST",
        "user_id": "05592fd9-45d8-492d-a768-b0eed11f69ae",
        "verified_at": "2022-04-20 22:59:47.746967Z"
      }   
    ],  
    "approved_ips": ["192.168.1.1", "192.168.1.2"], 
    "birthday": "2022-04-20 22:59:47.746967Z",
    "custom_attrs": {}, 
    "email": "newsuperuser9@example.com",
    "email_verified": "2022-04-20 22:59:47.746967Z",
    "ethnicity": "Hispanic or Latinx",
    "first_name": "User",
    "gender": "Agender",
    "height": 4.5,
    "id": "05592fd9-45d8-492d-a768-b0eed11f69ae",
    "last_name": "Super",
    "latest_pp_accept_ver": 2,
    "latest_tos_accept_ver": 3,
    "locked_at": "2022-04-20 22:59:47.746967Z",
    "locked_by": "05592fd9-45d8-492d-a768-b0eed11f69ae",
    "nick_name": "", 
    "phone_numbers": [
      {   
        "id": "ef82eaa9-b12f-4b0f-9801-f3edd63192aa",
        "number": "9876543210",
        "primary": false,
        "user_id": "05592fd9-45d8-492d-a768-b0eed11f69ae",
        "verified_at": "2022-04-20 22:59:47.746967Z"
      },  
      {   
        "id": "82e8d21b-896e-4edb-9af5-d29ec70ab65a",
        "number": "1234567890",
        "primary": false,
        "user_id": "05592fd9-45d8-492d-a768-b0eed11f69ae",
        "verified_at": "2022-04-20 22:59:47.746967Z"
      }   
    ],  
    "preferences": {
      "display_middle_initial_only": true,
      "display_name_pref": "nick_name",
      "theme": "light"
    },  
    "privacy_policy_accept_events": [
      "accept": true,
      "tos_version": 12,
      "timestamp": "2022-04-20 22:59:47.746967Z"
    ], 
    "privacy_policy_accepted": false,
    "race": [
      "American Indian or Alaska Native",
      "Asian"
    ], 
    "roles": [
      "admin",
      "user"
    ],  
    "sex": "Female",
    "tos_accept_events": [
      "accept": true,
      "tos_version": 12,
      "timestamp": "2022-04-20 22:59:47.746967Z"
    ], 
    "tos_accepted": false,
    "username": "newsuperuser9",
    "weight": 145.67
  }
}

Some of the fields are a json type of string but are actually enums. These follow the Facebook guidelines but here's where they're defined in malan:

Ethnicity: https://github.com/FreedomBen/malan/blob/main/lib/malan/accounts/ethnicity_enum.ex#L42-L43 Race: https://github.com/FreedomBen/malan/blob/main/lib/malan/accounts/race_enum.ex#L61-L65 Gender: https://github.com/FreedomBen/malan/blob/main/lib/malan/accounts/gender_enum.ex#L42-L93 Sex: https://github.com/FreedomBen/malan/blob/main/lib/malan/accounts/sex_enum.ex#L42-L44