Jul 04, 2022·2 min read

Authorization and Registration in AppMaster

Learn about Sign-In/Sign-Up processes in mobile applications

Authorization and Registration in AppMaster

In this article, we are going to give you an example of how to set up sign-in \ sign-up processes for mobile applications. First of all, imagine that we already have a page in our mobile application, representing a list of books. Each book has its own title, author name, genre, and image cover.

Let’s start from the Sign-In page first and create a new blank screen (View).

The screen’s layout contains a container to align its content. Email field component and pass field component are inside this container. Button for triggering the authorization process is also inside it. Screen’s component tree looks as follows:

In the designer it looks like

The first part of the authorization business process related to the button’s workflow and you can see it on the picture below:

  • It is triggered by on-tap action;
  • First of all it gets the values (Get Properties) from input fields (email and password);
  • The values from inputs are passed into the POST /auth business process block.

  • If the request is successful (If-Else = true valuation) then the new Auth Token is assigned to the current user who executed this request;
  • After the Auth Token is assigned - the user has to be navigated to the new screen (Books list page in this example).

  • If the request is not successful - then the email field and pass field component statuses are to be updated (Update Properties) with the corresponding messages (Validate Message) and statuses (Validate Status)

That’s it regarding the authorization. The next step is to make a registration logic for our application. Let’s create a new blank screen (View) as we already did for the sign-in logic. Don’t forget to fill it in with the components.

Screen components tree looks like:

Screen layout on the screenshot below:

Sign-Up business process related to the button’s workflow and is triggered by on-Tap action. The first part of the business process is shown on the screenshot below.

  • As was already mentioned the business process starts from on-tap action;
  • First of all, all the values from inputs has to be obtained for further processing (Get Properties)

  • Both passwords have to be compared with each other. In order to do this they have to be converted into string format (To String);
  • Comparison is being handled by Equal logic block.

  • If passwords are matched then the values from inputs are to be provided into the POST /register block;
  • If the registration is successful (validated by if-else block) then the new Auth Token is assigned to the current user;
  • After the token is assigned the user has to be navigated to the new page (Books list in this example).

  • If the password are not matched (False validation of the first if-else block) or the registration is not successful (False validation of the second if-else block) then the input components statuses (Validate Status) and messages (Validate Message) are to be updated with the corresponding values.

That’s all we need for registration logic.

The last step we need to make is to make sure that the user will be navigated to the correct page (Sign-In page in this example) once he is signed in. Also we need to add the logic that the user will be navigated to the Books list page if he is already signed in and has an active Auth Token. This can be done in the Triggers and Actions section.

The trigger which is responsible for on-launch actions - is the onLaunch trigger. It is usually predefined by default for every new application, but we want to create some custom logic here. So the final result looks like this on the screenshot below:

  • Firstly, it gets the latest Auth Token of the current user
  • Then, it sends a request to the server which requires authentication. For example, GET /user/profile request since it accepts the Auth Token
  • The success of the request is validated by the If-Else block

  • If the request is successful (True validation of if-else block) then the user is navigated to the Books list screen;
  • If not - he is navigated to the Sign-In screen.

That is how easy Sign-In/Sign-Up processes in mobile applications on the AppMaster.io platform. Full video tutorial:

Conclusion

The no-code platform AppMaster makes it easy to create your mobile app. You can always register on the platform and check out all the functionality.

FAQ

How do I build a sign-in screen in AppMaster?

Create a blank Sign-In view with email and password fields, then add a button that runs the authorization workflow when the user taps it.

How does the sign-in button send user credentials?

Use Get Properties blocks to read the email and password field values. Pass those values to the POST /auth block to send the sign-in request.

What should happen after a successful sign-in?

After a successful POST /auth request, assign the returned Auth Token to the current user. Then send the user to the Books list or another protected screen.

How do I show sign-in errors to users?

Update the relevant input fields with a Validate Status and Validate Message. Show the user which value needs attention instead of sending them away from the form.

Do I need a separate screen for registration?

Create a separate Sign-Up view with the registration fields and a button. Attach an on-tap workflow to that button, just as you do for sign-in.

How can I check that two passwords match?

Read both password values with Get Properties, convert them to strings if needed, and compare them with an Equal block. Only continue to registration when they match.

What does the registration workflow do after passwords match?

Send the form values to the POST /register block after the password check succeeds. If registration succeeds, save the new Auth Token for the current user.

What should I do when registration fails?

Set validation messages and statuses on the password fields when the passwords differ. Use the same approach if the registration request returns an error.

How do I keep signed-in users out of the sign-in screen?

Use the onLaunch trigger to read the current user's Auth Token. Then call an authenticated endpoint, such as GET /user/profile, to check whether the token still works.

What should the app do when an auth token is invalid?

If the authenticated request succeeds, navigate to the Books list screen. If it fails, send the user to the Sign-In screen so they can authenticate again.

Easy to start
Create something amazing

Experiment with AppMaster with free plan.
When you will be ready you can choose the proper subscription.

Get Started