This blog post talks about the implementation of the checkRegistration.json API on the SUSI.AI server, which is a part of the AAA system. The API endpoint to check if an email address has been registered for SUSI is https://api.susi.ai/aaa/checkRegistration.json
It accepts one compulsory url parameter –
- check_email – It is the parameter that contains the string type email address which the user enters in the email address field of the login screen.
The minimalUserRole is set to ANONYMOUS for this API, as initially the registration status of the email address is unknown.
- The parameter is first extracted via the post object that is passed to the serviceImpl function. The parameter is then stored in a variable. If the parameter is absent, then it is set to the default value null.
- There is a check if the email is null. If null, an exception is thrown.
- This code snippet discusses the above two points –
- Set the credential variable of type ClientCredential by passing the parameters passwd_login and checkEmail to the ClientCredential constructor.
- Finally pass this credential variable to the getAuthentication method defined in the DAO to return the authentication object.
- The authentication object then invokes the authentication.getIdentity() method. If the result is null, it means the email address has not been registered yet and vice-versa.
- Internally, the entire checking procedure is done from the authentication.json file that is stored in data/settings/ directory of the server.
- The response object is then sent with three key values mainly, apart from the session object. They are –
- accepted – true – It tells that the API call has been successful.
- exists – It tells that the email address has already been registered.
- check_email – It is the same email address that was sent as a query parameter.
Here are the important code snippets –
- Continuation of the first code snippet –
- Sample response of checkRegistration.json API endpoint –
The API development was done in the above explained way. This API will be used in improving the authentication flow in the Android client, where, if an email address has already been registered, then the user would be taken to the ‘Enter Password Screen’ otherwise he/she would be directed to the Signup screen.
- Learn about Application Programming Interface (API)
- A blog on API development – An Introductory Guide
- Check out some good login/signup UI flows