Login - Capi-Metaverse/Template GitHub Wiki

Table of Contents

Introduction

The login has a common (visual) interface for all the components that form it and a common (code) interface for the reuse of functions.

  • The common visual interface consists of a backgraund and a series of messages to provide feedback to users.

  • The common interface(code) is called ILogin, and contains 3 abstract methods, which need different properties to work

    • Register: contains usernameInput, emailInput, passwordInput

    • OnReset: contains emailInput

    • Login: contains emailInput, passwordInput

These methods are intended to be adaptable to the Login tool you want to use, be it PlayFab, an external server or an internal server.

Login with PlayFab

Next we are going to see how it works and the different parts which form our login using PlayFab.

We use as main Script LoginPlayFab which inherits from the ILongin interface, LoginPlayFab contains all the necessary calls to Playfab, so that the users can log in, the main functions that this Script contains are:

  • Login: makes a call to Playfab, checking that the email and password are correct, checks the user’s role and the group he belongs to, and if the user has never logged in to the application, initialises a tutorial.

  • Register: makes a call to Playfab, sending Username, Email and password, to create the new user, assigns a group and creates the deblockable achievements for the user.

  • OnReset: makes a call to Playfab, checking that the email entered exists and sends an email to allow the password to be changed.

We have an interface division, based on specific prefabs for each section that makes up the Login, each one containing its own script.

  • PanelLogin: this prefab contains the LoginScript, which calls the Login function of the PlayFabLogin Script.

  • PanelRegister: this prefab contains the RegisterScript, which calls the Register function of the PlayFab script, fulfilling a series of validations.

  • PanelResetPass: this prefab contains the RessetPasswordScipt, which calls the OnRest function of the PlayFab script.

LoginIMG

To switch between the use of PlayFab to another server, it is necessary to create a new script that contains the functionality you need, similar to LoginPlayFab, once this is done, in the functions of each prefab add an else or change the code to adapt it to what is needed. image

⚠️ **GitHub.com Fallback** ⚠️