Account Management

Last Updated on : 2024-06-12 10:22:48download

This topic describes how to manage user accounts.

Account types

Type Meaning
Brand owner account Users cannot create this type of account.
The account that you receive upon purchasing the OEM SaaS. It is associated with your OEM SaaS domain.
Enterprise main account The account that you create on your own. It has all privileges within the organization and can create or delete projects.
Enterprise sub-account The account that an enterprise main account creates in their SaaS. It is granted access to specific features.

Create an account

Creating a main account on the mobile app is not supported. Go to the Smart Commercial Lighting platform to create an account.

Log in

The account system is designed with the one-to-many model, with one account assigned to multiple merchants. In the commercial lighting scenario, the system is limited to the one-to-one relationship, with one account uniquely assigned to one merchant. There is no need to specify the merchant code for login, because the system can retrieve the unique merchant associated with the current account.

Supported login methods:

  • Log in with a password

  • Log in with a verification code

  • Log in with a third-party account: Implemented in tandem with the Commercial Lighting OpenAPI.

    Account Management

    Procedure

    1. The third-party server grants an account access to the Tuya IoT Development Platform. The third party specifies the type of account, such as a system or employee account. For example, businesses, stores, and projects.
    2. After authorization, the third-party server uses the username and country code to request a ticket from Tuya.

    Scenario

    1. Concatenate the Tuya’s system domain and the ticket to enable login-free redirection. Example: lighting.console.tuyacn.com?ticket=xxx For example, redirect users to the system website or an H5 page for device control.
    2. The Commercial Lighting App SDK gets the session status using the ticket to access all features of the SDK.

API description

- (void)loginMerchantByTicket:(nonnull NSString *)ticket
         multiMerchantHanlder:(void(^_Nullable)(NSArray<ThingSmartMerchantModel *> * _Nonnull merchantInfos))multiMerchantHanlder
                      success:(nullable ThingSuccessHandler)success
                      failure:(nullable ThingFailureError)failure;

Parameters

Parameter Description
ticket The ticket obtained during the authorization process.

Sample code

    [ThingSmartUser.sharedInstance loginMerchantByTicket:@"" multiMerchantHanlder:^(NSArray<ThingSmartMerchantModel *> * _Nonnull merchantInfos) {
    } success:^{
    } failure:^(NSError *error) {
    }];

Recover/reset password

Recover or reset the password if users forget it. The steps for both operations are identical. Permission is verified before the request for the list of merchants. Follow these steps:

  1. Get the verification code for resetting the password.
  2. Pass the verification code to get the list of merchants.
  3. Get the respective merchant and invoke the reset password method to change the password.

For more information, see Recover/Reset password.

Log out

The SDK manages the storage and deletion of account information, freeing you from taking care of its security and synchronization.

After successful login, the SDK will store the account information in the cache. After users log out, the SDK will clear the cache. You can handle your business logic after a successful callback.

For more information, see Log out.

Delete account

To delete an enterprise main account, submit a service ticket for manual review.

Bind account

Currently, the merchant account system does not support binding an account with a phone number or email address.

Query user information

After a successful login, the account name and role will be returned as the account properties. To get additional properties such as nickname and avatar, invoke the getMerchantUserInfoWithSuccess: failure: method.

The getMerchantUserInfoWithSuccess: failure: method can also be used to sync additional user information between apps.