Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
C++

Adding user account creation to your BaaS enabled apps

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.

kinvey_5f00_11944-3924882

parse_5f00_11947-3678280

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.

backendusers_5f00_11950-6768126

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:

kinveyacct1_5f00_11956-7434096

See What's New in 12.2 Athens See What's New in 12.2 Athens Dev Days of Summer 2-24

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Director of Product Management, Developer Tools Idera, Inc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES