Login for the first time only, even if email not confirmed

When the user registers his account, I want to log in to him and give him a token and let him use the app, and in the second login, he should confirm his email to let him log in.
On the other hand, I have functionality that let the user change his email, and when he changes it, the user status become EMAIL_CONFIRMATION_PENDING
So when I enable the Require Email Confirmation, this logic while being inapplicable, change email works fine, but login without email confirmation for the first time is forbidden(can’t log in cause email isn’t confirm)

Hello @adel_kasno

There is no such ability to allow user login the first time without confirming email and then disallow it.

However, in my mind there is some kind of workaround:

  1. disable the “Require Email Confirmation”
  2. add a beforeLogin event handler and check there the userStatus property of the user
  3. also to have an extra column which determines this is the first login or not
  4. at the end, I believe you can control user’s login process and reject anyone who goes beyond your design

if i disabled it, then when changing email address and even on registration, the userStatus will not become EMAIL_PENDING_CONFIRMATION
@vladimir-upirov

I want to solve this: Require Email Confirmation enabled, and let the user log in for the first time.

Hello @adel_kasno,

As @vladimir-upirov already said

There is no such ability to allow user login the first time without confirming email and then disallow it.

User should confirm the email before he or she can login.
I’ve created the internal ticket BKNDLSS-26237 to discuss the possible cases for solving this question.

Regards,
Olha

ok i hope this will be added, another question, can I enable Require Email Confirmation by code ?
@olhadanylova @vladimir-upirov

Hi @adel_kasno !

We have discussed your case. The only way to solve your problem - is to create custom service for users registration and register users from it - Backendless allows to specify explicitly user status when user registered from CloudCode.
You will need to create custom CloudCode service with method which will receive user data for registration and will call Backendless register API method explicitly passing “ENABLED” in “userStatus”. As result you will get new user with “confirmed” email and user token which you will be able to use in future for user authentication.

It is the only option for you since it is not safe to introduce behavior which you have described.

I would recomend you to revise your decision about ignoring email confirmation during registration since you will be unable to guarantee that user has valid email in your app with such registration flow.

another question, can I enable Require Email Confirmation by code ?

No, unfortunatelly there is no such option due to security reasons

Regards, Andriy