Adding user account creation to your BaaS enabled apps

Posted by on in Blogs
In RAD Studio XE6, we introduced our BaaS (Backend as a Service) support. This includes components for both Kinvey and Parse. Part of our component pack is the TBackendUsers component which is designed to be hooked into either the ParseProvider or KinveyProvider component.

My sample application that I am building as part of this tutorial will allow me to create a user account on either Kinvey.com or Parse.com, with a defined username and password. If the account creation was successful, a message dialog will be shown. If the username already exists inside my BaaS account, it will automatically return a message, telling me to choose a different username. In this application, I am also using the Jet style pack which is included in our bonus pack if you purchase a Professional or higher edition of RAD Studio, Delphi or C++Builder XE6 by June 30th, 2014.



UI specs:

I placed a TToolbar onto my form, with a TLabel parented to it that is aligned to Center with a Stylelookup property of 'toollabel'.

I also placed a TListbox onto my form with one Listboxitem that contains 2 TEdits (one for the username, one for the password) and a TSpeedbutton (you can also use a TButton).

For the Password edit, you can check the 'Password' property, but I am leaving it unchecked for demo purposes.



The Listbox Groupingkind property is set to Grouped and the Stylelookup property is set to 'transparentlistboxstyle'. The Listbox is aligned to Center with a Bottom Margin of 100, and a Top Margin of 30.

The Stylebook that I dropped onto my form has the AndroidJet style assigned to it. I also changed the font color to green in the TextSettings property.

BaaS components:

Place either a TParseProvider or TKinveyProvider component onto your form and enter your credentials. You will need to go to Parse.com or Kinvey.com to sign up for an account.





Next, add a TBackendUsers component and set the provider to ParseProvider1 or KinveyProvider1, depending on the BaaS provider that you have selected for your project.



My last step was to setup the on-click event that is fired when the user clicks on 'Create' to sign up for the account.

Object Pascal:
procedure TAccountSignup.btnCreateAcctClick(Sender: TObject);

var

ACreatedObject: TBackendEntityValue;

begin

BackEndUsers1.Users.SignupUser(Username.Text, Password.Text, nil, ACreatedObject);

ShowMessage('Account created');

end;

C++:
void __fastcall TForm1::btnCreateAccountClick(TObject *Sender)

{

TBackendEntityValue entity;

BackendUsers1->Users->SignupUser(Username->Text, Password->Text, NULL, entity);

ShowMessage("Account created");

}

Below are some screenshots of my app in action:













About
Gold User, Rank: 5, Points: 558
Senior Product Manager, RAD Studio

Comments

  • Guest
    Christian Artinger Friday, 2 May 2014

    Hi,

    thank you for that Tutorial. Signing up a new User is quite easy. But maybe someone know how to Login as a User when Querying something. Here's my example:

    I have a few Tables at parse.com. And i like to give this tables User-Persmissions, i. e. only User "A" can Query Objects from Table "AA". With the "TBackendUser"-Component i can Check if the Login has worked. But I didn't make it to give the Logged-In User to the TBackendQuery. I get always the Error "Parameter does not identify a logged in user" when I pass the TBackendEntityValue from TBackendUsers::Users::Login() to TBackendQuery::QueryApi::Login().

    So at the moment, i have in the User-Table Columns i. e. "AllowUserEdit". When I login, I Save this value and my Application checks them. But I would prefer that this is made by the Permissions in Parse.

    Someone have a Suggestion?

  • Guest
    Godfrey Fletcher Friday, 2 May 2014

    Some newbie questions? If I want to create an app that sends out notifications to users or individual users.
    Does each user need to register with the BAAS service to receive notifications?
    if so:
    Can you send a notification to a individual user, using the ID?
    What if the user's mobile number changes will the notification still reach them?

  • Guest
    sarinadupont Monday, 5 May 2014

    Hi Christian,

    Glad you liked the tutorial.
    This error message indicates that the AuthToken property of TBackendEntityValue is blank.

    Login code should look something like this:

    var
    LLogin: TBackendEntityValue;
    ...
    BackendUsers1.Users.LoginUser('elmo', 'sesamestreet', LLogin);
    // Expectation
    Assert(LLogin.AuthToken '', 'No AuthToken');

    BackendQuery1.QueryApi.Login(LLogin);
    // Expectation
    Assert(BackendQuery1.QueryApi.Authentication = TBackendAuthentication.Session, 'Not logged in');

    Hope this helps.

    Regards,
    Sarina

  • Guest
    sarinadupont Monday, 5 May 2014

    Hi Godfrey,

    Inside your BaaS provider account, you can select to send a notification to either a specific user or all users of your application. You can create user accounts via the BaaS admin panel (dashboard) or allow users of your application to sign up for an account. The user's mobile number is not really related to the notification. For example, a person can download your app and sign in with their specific username and password on a phone and a tablet, receiving notifications on both devices.

    Regards,
    Sarina

  • Guest

    [...] Adding user account creation to your BaaS enabled apps From blogs.embarcadero.com - Today, 1:51 AM In RAD Studio XE6, we introduced our BaaS (Backend as a Service) support. This includes components for both Kinvey and Parse. more... Delete the scoop? [...]

  • Guest
    Christian Artinger Monday, 5 May 2014

    Hello Sarina,

    thank you for your answer. My Code looks like this (I'm using C++):

    TBackendEntityValue entity

    BackendUsers->Users->LoginUser("MyUserName", "MyPassword", entity);

    if (entity.AuthToken.IsEmpty())
    ShowMessage("no auth token");

    BackendQuery->QueryApi->Login(entity);

    I get an AuthToken (I looked in the Debugger and the Message is not shown, so all seems to be good), but when "BackendQuery->QueryApi->Login()" is executed I get the mentioned error...

    Regards,

    Christian

  • Guest
    Godfrey Fletcher Tuesday, 6 May 2014

    How do you register a device ID for a user. As I understand it, you need at least one registered device ID per user in order to send push messages.

  • Guest
    Christian Artinger Wednesday, 7 May 2014

    Hi Godfrey,

    install an App on your Device that requests or sends some Data from your Parse-App and the Device should be registered automatically.

    Regards,

    Christian

  • Guest
    Godfrey Fletcher Wednesday, 7 May 2014

    Hi Christain

    Thanks. I guessed that might be the way but, I have not gone as far as creating an app yet. I am just experimenting with the Kinvey website. I can add a user but cannot find anywhere to add a device. Would like to send test push message from their website.

  • Guest
    Christian Artinger Wednesday, 7 May 2014

    Hi Godfrey,

    I don't know if you're using iOS or Android. I can only say something to the iOS side. And here it is so that you need for each app a specific certificate (if you want to use Push-Notifications). So this Certificate is linked with the App and you need to install the App to get Push-Notifications.

    But as said above I don't know if it's the same procedure with Android...

    Regards,

    Christian

  • Guest
    Godfrey Fletcher Wednesday, 7 May 2014

    I am using Android

  • Guest

    [...] a recent blog post, I covered how to add user account creation to your BaaS enabled apps. Our BaaS support that we [...]

  • Please login first in order for you to submit comments
  • Page :
  • 1