If we have condition for `FI , Else If, else ` it would be much easier building function in xano.

Options

So I am building a login function stack, what I want to do is to make it in one call. like below;

I found if we had an "IF, if else, else "statement it would be much easier to work in Xano,

Currently, I have to do it with " IF, Else " which is becoming lengthy and tedious.


Check if the user state is REGISTER,
check the record for the user and check
check password matches with the repeat password.
if: user recode = false & password match = true
create user

create token

return

else :

if user recode = false & password match = false

return " password not match"

else:
if user recode = true & password match = true.
check user.password = password ( input by user)
if the above check is true.
create token

retuen

else

return ( user exist but pass not macth with user)


Else:

this is the login flow



*************************************

Tagged:

Comments

  • Liz Anaya
    Liz Anaya Member, Administrator

    ADMIN

    Options

    Hi @Baloshi69 ! 👋

    Have you looked into the Precondition utility function? It's helpful if you want to enforce that something is true and create an error message in the event it is not true. It might help with some of the conditions you want to check without making the if…else statements lengthy and tedious.

    An example of how Preconditions are used can be seen in the function stack of the /auth/login endpoint that is automatically auto-generated for the user table (if you opted into this option when you created your workspace). I know this isn't your exact use case, but it might help give you some ideas for how to check some of the conditions.

    Let me know if this is helpful for what you are trying to do. 😊

  • Baloshi69
    Baloshi69 Member
    Options

    @lizanaya I know Precondition and yah they are helpful. but not as much as IF, Else if, Else would be.