Authenticate on a single mobile or device

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)

Just noticed, you are using separate if statements instead of one continuous if/elseif/elseif, as in my solution...

your blocks

my blocks

image

Probably breaking the logic.

Also I noticed I made a data entry error for setting times adding an extra 0 to 3600000 (1 hour). I have updated my original post. (Should not cause a huge issue just 10 hours instead of 1)

I note that your timestamp is:

image

1 Like

perfect
how a 0 can change things :rofl:

one last question
How could I assign an expiration time to the labels?
"first and second" containing (usus)
FB


these are my rules:

{
"rules": {
".read": "now < 1767157200000", // 2025-12-31
".write": "now < 1767157200000", // 2025-12-31
}
}

For example
primero
1767157200000", // 2025-12-31
segundo
1756080000000", // 2025-08-25

Your rules have nothing to do with the timestamps.

Yes I know but I would like to give a time frame, for example only to:
primero
without affecting
segundo
Is it possible?

What are you talking about, your secure rules or your app ?
[edit]
I have just read your previous post again. Each timestamp relates to a different user, so it make no sense to try and order the timings under usus.

something like this firebase rules

limit time to tags

Sorry for the question, maybe it's something unusual.
but it's worth asking

You would need a different node (tag or bucket) for each of those rules:

{
  "rules": {
    "primero": {
      ".read": now < 1767157200000,
      ".write": now < 1767157200000
    },
    "segundo": {
      ".read": now < 17560800000,
      ".write": now < 17560800000
    }
  }
}

image

something is wrong row 4

Sorry I left out the double quotes around each "now"

1 Like

thank you :+1:

TIMAI2
I have a problem

I have 2 users, one in Gmail and the other in Hotmail, both with the same password.
everything runs well in the registration, entry to (screen2) everything ok.

but sometimes this message appears. I realized that this only happens when logging in.
I repeat this is rarely, not always.

How can I improve it?
I attach a video

blocks

new131224 (3).aia (11.7 KB)

Read the error message


And compare with your blocks

That number is the system time and the response content is that JSON string... as ypu can see yourself, it does not make much sense to compare those 2 values, does it?

Taifun

I am not sure why you are getting back the timestamp and the siginin data in one go, unless you have modified your blocks from my solution, not setting the action variable correctly or something.

The workflow should be:

User signs in, this returns their idToken and other info. The idToken is then used to to fetch the timestamp, and then to allow/deny access.

Looking at your aia, I see you have not adjusted all your if statements to if/elseif as I suggested

image

Look at my example, again, and correct your blocks.

Or better still, take a few steps back, start with my example as a base, then carefully, testing at each step, modify to your liking.