3 Replies Latest reply on Jan 24, 2017 4:52 PM by mrosenhek

    Account Creation via Script

    mrosenhek

      Background:

      I am building a solution that allows  users to create their own account. That in itself is easily done.

       

      However, if another user can create an account with the same name. But, when they attempt to login using that account, the password they enter will not allow them access because the password they think they chose, is not associated with the account name. Kind of hard to expalin this.

       

      Solution:

      Prevent an account from being created if the name already exists. So far I see no FM function that can give an error if an account with that name already exists. I figure I could have a table of logins (each time somebody logs in a record is created) and test to see if the new account is valid through a relationship tot hat table. If it is valid then I can prevent the creation of the new account. But I still do not know how to trap for that. Also, the solution must work on mobile devices, through WD, and over FM network.

        • 1. Re: Account Creation via Script
          philmodjunk

          If the users are to create their own account, that would mean that you have some fields where the user enters an account name and password. At the time they do this, you can update a table of account names and add the new account name to this table before creating the new account. Set up a unique values validation on the account name field in this table and the user will get an error message.

           

          And a script can trap for the error if you want to script it.

           

          Say the user enters a new account name into a global field: Globals::gAccountName

           

          The script might work like this:

          Go to Layout ["Accounts" (Accounts) ]

          New Record/Request

          Set Field [ Accounts::AccountName ; Globlas::gAccountName ]

          Set Error Capture [on]
          Commit recordsIf [ Get ( LastError ) > 0 ]

             Revert Records

             Show Custom Dialog [Globals::gAccountName & " is already in use. Please enter a different account name" ]

          • 2. Re: Account Creation via Script
            mrosenhek

            Thank you for responding. Yes, I am aware of (and do have) a table of logins. I was hoping to find a way in FM to check against the actual accounts under FM security. Cheers.

            • 3. Re: Account Creation via Script
              mrosenhek

              That is similar to the old way I used to do this. I created a user record. Not anymore. The fields that are set are all globals. Thanks for responding.