FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login
    1. Home
    2. kasir-barati
    K
    • Profile
    • Following 0
    • Followers 0
    • Topics 7
    • Posts 49
    • Best 2
    • Controversial 0
    • Groups 0

    Mohammad Jawad (Kassir) Barati

    @kasir-barati

    Passionate Fullstack engineer who is pioneering in the world of software with state-of-the-art technologies. Eager to learn, love to write code and tests. Wanna talk business? Contact me: linkedin.com/in/kasir-barati/

    2
    Reputation
    4
    Profile views
    49
    Posts
    0
    Followers
    0
    Following
    Joined Last Online
    Location Bremen, Germany Age 30

    kasir-barati Unfollow Follow

    Best posts made by kasir-barati

    • RE: Custom registration for user, and use registration response (and token) to continue process with this logged user

      Not sure exactly if this is what you need but probably you can implement your own backend app to communicate with FusionAuth however you see fit. Just like what I did here in NestJS. Then in my react app I have a normal form and then sends an HTTP request to my backend endpoint. So in other word I am not using startLogin helper function.

      Yes, I know it is not angular. But just to light your creativity I thought it is a good idea too look at it from a different perspective.

      BTW I appreciate it if you could give my repo a star if it did help you.

      posted in General Discussion
      K
      kasir-barati
    • How can I configure a fusionauth docker image from scrach using only terraform

      I tried to have a fusionauth instance up and running with docker compose file as the official doc stated here. but the only problem with that is that I do not wanna use kickstart.json to configure my fusionauth. And then I realized that without a apiKey my terrafrom resources cannot do anything since they will get a connection refused since they do not have any apiKey, so what can I do?

      Is there any kind of docker env or java env to pass to the container while creating it to create the api key automatically while creating container.

      Here you can find more context

      posted in Q&A
      K
      kasir-barati

    Latest posts made by kasir-barati

    • RE: Unique username and email at the same time

      Ahhhhhh, this error is getting on my nerves: You must specify either the [user.email] or [user.username] property. If you are emailing the user you must specify the [user.email]

      The thing is that I am setting the user's email to enable them login and then inside data object I am setting a username for the future use, but as of now it is kinda random and automatically generated at the registration time.

      So why the heck is FusionAuth SDK for Typescript returns a client response with this error is a mystery for me.

      It should not do it under normal circumstances, according to my understanding you can only use email or username, and I am setting email as the way to login but username is inside the data and that should not interfere with anything IMO.

      I am trying to update this user that was created automatically with Terraform:

      resource "fusionauth_user" "you-say-temp-user" {
        tenant_id                = fusionauth_tenant.you-say-tenant.id
        email                    = "souma.kazuya@you-say.com"
        first_name               = "Souma"
        last_name                = "Kazuya"
        password                 = "souma.kazuya"
        skip_verification        = true
        password_change_required = false
        data = jsonencode({
          username : "souma_kazuya"
        })
      }
      

      And here is the TS code that I am using to update it, as you can see I am not even touching username:

      await this.fusionAuthClient.updateUser(id, {
        user: {
          lastName: updateUserInfoDto.lastName,
          firstName: updateUserInfoDto.firstName,
        },
      });
      

      It would be really great if someone could leave a comment setting myself aside ありがとう.

      posted in Q&A
      K
      kasir-barati
    • RE: Unique username and email at the same time

      Coming back to this thread to update you on something really weird, FusionAuth is throwing an error when I try to have email and user.data.username. I thought FusionAuth really do not care about what is inside the data. Or maybe I am misconfiguring somethings 😕.

      It's error message: You must specify either the [user.email] or [user.username] property. If you are emailing the user you must specify the [user.email].

      posted in Q&A
      K
      kasir-barati
    • RE: Unique username and email at the same time

      I can also think of one ugly solution which is not very pleasant for the users and that would be generating usernames by concatenating firstName, lastName and a random hexadecimal string.

      posted in Q&A
      K
      kasir-barati
    • RE: Unique username and email at the same time

      It seems like I do not have any mean to implement this in FusionAuth, I search for a way to define new constraints in DB for user.data field but no luck.

      Then the other option is a vulgar way of doing it, fetching all users and then looping over users and comparing the user.data.username with the new one. It is not gonna work in a medium-size or large user base app.

      I can think of one more option which is saving all usernames in my MongoDB database which can work but is not what I would volunteer for it.

      Any suggestion?

      posted in Q&A
      K
      kasir-barati
    • RE: Enforcing attributes on a user

      Hey @dan,

      I guess I need something similar for user.data.username. I need to define a rule on this custom user data to be unique in my app or tenant. As of now I really do not care about tenant or app since I only have one tenant and one app in my FusionAuth.

      So I've asked this Q&A and I need to enforce uniqueness for this data. But dunno how to do it. Any suggestion?

      posted in Q&A
      K
      kasir-barati
    • RE: Unique username and email at the same time

      GH issue: https://github.com/FusionAuth/fusionauth-issues/issues/185

      posted in Q&A
      K
      kasir-barati
    • Unique username and email at the same time

      username, and email uniqueness.

      We wanna let users to register with unique usernames, and email addresses. I know that we can store the email/username in the user.data field, which is not required to be unique. And we know that we cannot specify username and email at the same time. Look at this error message you'll get when you try to specify both:

      {
        statusCode: 400,
        exception: {
          fieldErrors: {
            'user.email': [
              {
                code: '[blank]user.email',
                message: 'You must specify either the [user.email] or [user.username] property. If you are emailing the user you must specify the [user.email].'
              }
            ],
            'user.username': [
              {
                code: '[blank]user.username',
                message: 'You must specify either the [user.email] or [user.username] property. If you are emailing the user you must specify the [user.email].'
              }
            ]
          },
          generalErrors: []
        }
      }
      

      I was trying to update a user with following code:

      await fusionAuthClient.updateUser(id, {
        user: {
          lastName: updateUserInfoDto.lastName,
          firstName: updateUserInfoDto.firstName,
          uniqueUsername: updateUserInfoDto.username,
        },
      });
      

      So here is a similar Q&A: https://fusionauth.io/community/forum/post/3055

      Qustion

      I am trying to emphasis that just by saving username in user.data we will be able to have both username and email but applying rules such as uniqueness would require more manual work. Cannot we just tell FusionAuth to make sure that user.data.username should be unique in that application or tenant?

      I really do not like to check it manually in my backend considering how costly and inefficient it would be;

      1. Send an HTTP req to FusionAuth API to fetch all the users.
      2. Loop over them to verify user.data.username is not equal to the one that is entered by the user.
      3. Update user.

      Or at least that's how I though about its implementation.

      posted in Q&A
      K
      kasir-barati
    • RE: Unique usernames but not unique emails

      I tried to specify both username and email and I got this error:

      {
        statusCode: 400,
        exception: {
          fieldErrors: {
            'user.email': [
              {
                code: '[blank]user.email',
                message: 'You must specify either the [user.email] or [user.username] property. If you are emailing the user you must specify the [user.email].'
              }
            ],
            'user.username': [
              {
                code: '[blank]user.username',
                message: 'You must specify either the [user.email] or [user.username] property. If you are emailing the user you must specify the [user.email].'
              }
            ]
          },
          generalErrors: []
        }
      }
      

      So basically I guess my best bet is to manually enforce uniqueness of username in my backend. But it could have been less cumbersome if I could delegate it to FusionAuth.

      I guess what I am trying to emphasis here is the fact that just by saving username in user.data we will be able to have both username and email but applying rules such as uniqueness would require more manual labor. Cannot we just tell FusionAuth to make sure that user.data.username should be unique in that app or tenant?

      Side note: Since my question is deviating from the OP I'll create a new post and reference this one.
      posted in Q&A
      K
      kasir-barati
    • RE: NextJS + custom backend (NestJS)

      Thanks @mark-robustelli for your pointers, although I know how we can leverage lambda functions to customize our JWT tokens but I dunno if we can use them to change what GET /me endpoint returns. That's part of the reason I opt to develop my own backend to communicate with FusionAuth.

      posted in Q&A
      K
      kasir-barati
    • RE: Unique usernames but not unique emails

      Hey @dan,

      Would you mind if I ask you to differentiate between uniqueUsername and username both in updateUser and register in FusionAuth Typescript Client?

      await fusionAuthClient.updateUser(id, {
        // ...
        user: {
          uniqueUsername: username,
        },
      });
      await fusionAuthClient.updateUser(id, {
        // ...
        user: {
          username: username,
        },
      });
      await fusionAuthClient.register('', {
        // ...
        user: {
          username,
        },
      });
      await fusionAuthClient.register('', {
        // ...
        user: {
          uniqueUsername,
        },
      });
      

      Questions

      1. If I use username instead of uniqueUsername, then should I enforce uniqueness manually in my NestJS app?
      2. If I use uniqueUsername then will I have access to it as preferred_username returned by FusionAuth?
      posted in Q&A
      K
      kasir-barati