Authenticate on a single mobile or device

Here is a blank aia with a refresh button, so that the user can keep the session alive, as long as their existing session has not passed the hour.

You could add a clock to monitor the signin time and either automatically refresh, or alert the user that they need to do so to remain signed in, and to prevent them from signing in on another device :wink:

fbSingleSignIn_Timestamp_Refresh_blank.aia (6.9 KB)

Be aware that the keys for the idToken and refreshToken are different in the Signin json and in the Refresh json.

SignIn keys returned are: idToken & refreshToken
Refresh keys returned are: id_token & refresh_token

This is reflected in the blocks...

1 Like

1 I managed to log out from screen2
OK :heavy_check_mark:

2 no one can log in while on screen2
OK :heavy_check_mark:


3 suppose that while on screen2 the power goes out or the app turns off

procedure:
When I start screen2 I save in TinyDB (idToken and uid) then the power goes out.....

I turn on app

When I start screen1 I get these two data saved in the mobile's TinyDB and the time is automatically updated

and this happens:

Mobile 1
I turn on the app, log in and enter screen2
OK :heavy_check_mark:

Mobile 2
I turn on the app, log in and also enter screen2

This means that when I start screen1 the restriction is removed

What could I do?

We could play "what if I did this?" forever.

You will need to work out your own logic handling for such scenarios.

My blocks assume that the user will need to make a signin attempt first, before doing anything else, not an uncontrolled signout. If they can't signin, then they can't signout...

I think I have it

create a value (active) when starting screen2

when it turns off and I start again on screen1 I look for (active) the tinyDB I update time and then I clean it tinyDB

This works for the cell phone where it turned off

but it seems like I'm missing something
what do you think?

new131224.aia (8.4 KB)

as I said:

TIMAI2
Ask why I get this message?

implement
a text field for email
a text field for password

and I tried to order (global action) to understand it better by step

attached file

blocks

new_07012025.aia (9.7 KB)

Verify Password? Is this a different question for a different topic ?

It is the same project only I added a text field for email and password

The error is that you are comparing milliseconds (a big number) against the JSON responseContent.

You did not try to extract the part that holds the time value you want, you just shoved the entire responseContent down the mouth of the poor little math compare (<) block, which was just expecting a couple of numbers.

That's why it gagged.

what would be the solution?

because this does not happen to me when I put the email and password in a text variable


This way the message does not appear

In case you did not notice, I circled in red the location of the bad code.

I just saw it
This means that I should change the < symbol?

No, it means you have to learn to read error messages.

The error message showed the two sides of the < comparison.
It is at Authenticate on a single mobile or device - #54 by elmachi130 in case you forgot.

The left side has a time in milliseconds.
The right side has a big long piece of JSON text.
Worse, none of the values in that JSON have enough digits to be a milliseconds value.

So your problem is,
What are you trying to compare against the circled milliseconds value, and why are you doing that comparison?

1 Like

It is an example that they gave me

What I really need is what it says in the title.

I need that:
1 (a single user authenticates on a single device)
and if you try to log in on another device with the same email and password the message will be (You have already logged in on another device)

2 (if the power goes out or the phone turns off and the app closes without logging out while it is active)
When I restart, it updates the token and allows me to log back in only on this device since I save the UID, URL and token in the mobile's TinyDB.


From what I understand, the token changes every hour, which is why they modified the date in milliseconds.

and the power outage sometimes lasts more than an hour, that's why if I keep the start token it won't do the same thing again after more than an hour and I won't be able to log in again.

Which part of my proposed solution is not working for you ?

good day TIMAI2
here is the problem
Autenticar en un solo dispositivo o móvil - #54 por elmachi130

I get this message when I add a text field for email and password, everything else is like the example you sent

That is not in my solution. See @ABG's advice on where you are going wrong. The firebase request appears to be returning correctly.

In publication 44 is the file

#44 por elmachi130

I have been guided by that

I ran it again and the same message also appears.

I don't know if it has to do with the rules that changed until last year, which was

and now it is

I don't think so but it rules out all options.

What value is in your status tag?

What is in your responseContent ?

image

we started with "on,off" then you changed it with date

.aia
nuevo_07012025.aia (9,7 KB)