# Slug as Privacy Rule - No Login - Slug as a Token

**URL:** <https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702>\
**Category:** Need help\
**Created:** [February 20, 2022, 6:31pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702 "2022-02-20T18:31:37Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![augusto1](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@augusto1](https://forum.bubble.io/u/augusto1)\
**Post date:** [February 20, 2022, 6:31pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/1 "2022-02-20T18:31:37Z")

</div>

Hi There !

Is there a way to set “slugs” as a **Token** for Privacy Rule?

For Instance, I wanna send proposals from Bubble, and I’d like to set a randon token in the “slug”.  
So that, it is private for everyone, execpt for those how have the link itself…

For instance:  
[https://myapp.com/delivery/](https://myapp.com/delivery/) **01021e958b**  
The last part of my url is a “slug” used as a Token.

How do I set that in my Privacy Rules?  
Shoud be closed for anyone, except for those who have access to the link itself.  
**A must in this solution.: User with the link should not be asked to log in!**

Tks in advance for any idea !

---

<div class="post-metadata">

**Author:** ![lindsay\_knowcode](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/lindsay_knowcode/32/92967_2.png) [@lindsay\_knowcode](https://forum.bubble.io/u/lindsay_knowcode)\
**Post date:** [February 20, 2022, 6:48pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/2 "2022-02-20T18:48:04Z")

</div>

There is one neat Bubble trick I know for this problem. On page load of the linked page, grab and set the magic token value onto the user. eg something like:  
`on page load -> Current Users current token = extract magic token from URL` (regex or whatever or make your life easier by using a parameter).

Then on table that holds your special data have a privacy rule that is:  
`Currrent user's magic token is Data table's Magic token` (and leave on searching in the privacy rule)

Good luck 🙂

---

<div class="post-metadata">

**Author:** ![augusto1](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@augusto1](https://forum.bubble.io/u/augusto1)\
**Post date:** [February 20, 2022, 7:09pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/3 "2022-02-20T19:09:31Z")

</div>

But this way, if I understand, you’re “log in” by Url Token… isn’t it?  
I have to have an user for that… So, I’ve got to have may users for that !

If I understood, should not be pratical…  
Any other idea? 🙃

---

<div class="post-metadata">

**Author:** ![lindsay\_knowcode](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/lindsay_knowcode/32/92967_2.png) [@lindsay\_knowcode](https://forum.bubble.io/u/lindsay_knowcode)\
**Post date:** [February 20, 2022, 7:22pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/4 "2022-02-20T19:22:04Z")

</div>

The user does not have to login. Read about temporary users in the manual  
[https://manual.bubble.io/help-guides/working-with-data/authenticating-users](https://manual.bubble.io/help-guides/working-with-data/authenticating-users)

Why not put together a quick proof of concept to see if it works or not? 🙂

---

<div class="post-metadata">

**Author:** ![augusto1](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@augusto1](https://forum.bubble.io/u/augusto1)\
**Post date:** [February 20, 2022, 7:35pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/5 "2022-02-20T19:35:20Z")

</div>

That’s a great idea !  
I just have to grab some more knowledge to try it !  
Let’s see your video and have a try !  
Tks, for the moment, hands on ! 😆

---

<div class="post-metadata">

**Author:** ![augusto1](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@augusto1](https://forum.bubble.io/u/augusto1)\
**Post date:** [February 20, 2022, 8:19pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/6 "2022-02-20T20:19:49Z")

</div>

Sorry !!!

It writes to the database, but, for some reason Privacy Rules does not works this way…

1. I’ve created a field called “SlugNeat”, and set it picking data from url slug, to current’s user;

2. I’ve checked and it is working…  
 ![image](https://us1.discourse-cdn.com/bubble/original/3X/c/b/cbc38ff39d1ec2ba5a6eb2804c22bd07c527fc00.png)  
 ![image](https://us1.discourse-cdn.com/bubble/original/3X/7/c/7c54368e186116468d3b04c88bd6fd74217c18c7.png)

3. I’ve set a Privacy rule as below;

It does write in database (not logged in), but cannot read from it…

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/7/8/7877c5cfb8b7d21f62378b762c1f49e18619a07c.png)

**However… If I’m logged as any user, it does work.**

Any idea?

---

<div class="post-metadata">

**Author:** ![philip2](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/philip2/32/162181_2.png) [@philip2](https://forum.bubble.io/u/philip2)\
**Post date:** [February 20, 2022, 9:56pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/7 "2022-02-20T21:56:32Z")

</div>

Hi,

I worked on this exact thing a while back. If you’re logged in then it’s likely a separate privacy rule in action that allows you to see the data.

The issue I had was resolved by calling the data after the page load, or refreshing the page but that required some more complex workflows.

You could either trigger an update data workflow or set a custom state and link it to a conditional on the value in your element. This would then trigger the call from the database with the new privacy rule applied, after adding the token to the current user (logged in or out).

---

<div class="post-metadata">

**Author:** ![augusto1](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@augusto1](https://forum.bubble.io/u/augusto1)\
**Post date:** [February 20, 2022, 10:05pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/8 "2022-02-20T22:05:12Z")

</div>

So… there is a solution… that’s a good news !  
You could retrieve secure data from an logged out user? That’s the main point here…  
It seems to me that we can change data from an unlloged user, at least at Userdatabase…  
Doing some tests here to find a solution…

1. A state would be lost after refresh, isn’t it…?
2. So a backend workflow might be necessary…

Still working on a solution, any help would be great !

---

<div class="post-metadata">

**Author:** ![augusto1](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@augusto1](https://forum.bubble.io/u/augusto1)\
**Post date:** [February 20, 2022, 10:08pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/9 "2022-02-20T22:08:29Z")

</div>

I can write to an unlloged user database, that’s good ! 😆

I cannot retrieve any data, it does not seems to work like a logged in user as for Privacy Rules… 😅

---

<div class="post-metadata">

**Author:** ![aaronsheldon](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/aaronsheldon/32/115965_2.png) [@aaronsheldon](https://forum.bubble.io/u/aaronsheldon)\
**Post date:** [February 20, 2022, 11:50pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/10 "2022-02-20T23:50:23Z")

</div>

I built a page demonstrating a reusable pseudonymous login using tokens in the slug. Take a [look](https://bubble.io/page?type=page&name=jocly&id=littlelambdas&tab=tabs-2).

On my to do list is to support token login and regular login by setting up alias accounts for every user and then setting the privacy rules so that the alias can view the user account and vice versa.

---

<div class="post-metadata">

**Author:** ![augusto1](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@augusto1](https://forum.bubble.io/u/augusto1)\
**Post date:** [February 21, 2022, 2:03am UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/11 "2022-02-21T02:03:14Z")

</div>

Fantastic solution [aaronsheldon](http://forum.bubble.io/u/aaronsheldon)  
Simple and very clean…  
I’ll have to setup a workflow to clean my database (a lot of randon users…), but your solution is awesome, very secure !  
I was almost giving up…  
Tks !!!

So, the final solution (Maybe Useful for other users)

1. Create a random email;
2. Create an account with email in step 1;
3. Assign a temporary password;
4. Change password - credentials, using temp password step 3;
5. Set an User slug by GET Url parameters;

Beforhand Set a Privacy Rule using slugs in the data you wanna show comparing to User Slugs…

---

<div class="post-metadata">

**Author:** ![aaronsheldon](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/aaronsheldon/32/115965_2.png) [@aaronsheldon](https://forum.bubble.io/u/aaronsheldon)\
**Post date:** [February 21, 2022, 2:13am UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/12 "2022-02-21T02:13:02Z")

</div>

I’ll post up a reply with the detailed steps. This one is on our list to build a video around.

---

<div class="post-metadata">

**Author:** ![augusto1](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@augusto1](https://forum.bubble.io/u/augusto1)\
**Post date:** [February 21, 2022, 2:15am UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/13 "2022-02-21T02:15:02Z")

</div>

I’m sure many Bubblers don’t know it is possible !  
A video or a detailed solution might help other users…

Tks again!

---

<div class="post-metadata">

**Author:** ![lindsay\_knowcode](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/lindsay_knowcode/32/92967_2.png) [@lindsay\_knowcode](https://forum.bubble.io/u/lindsay_knowcode)\
**Post date:** [February 21, 2022, 5:24am UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/14 "2022-02-21T05:24:34Z")

</div>

I felt bad 🙄 that I might have given out some bad advice after seeing @aaronsheldon 👍 reply … so I went and double-checked- and I did make a mistake - sorry about that 🙃 . Aarons’s solution will work I think also … but I would do it slightly different with the privacy rules Maybe someone will point out a problem with my design … which would be good learning for me. But I think you can do this without creating temporary users.

The mistake I made was saying don’t make the token searchable in the privacy rule. I edited the original post to be correct.

Here’s a link showing how I would do it.  
[https://bubble.io/page?type=page&name=anonymous\_token&id=knowcode-tech&tab=tabs-3&subtab=Privacy](https://bubble.io/page?type=page&name=anonymous_token&id=knowcode-tech&tab=tabs-3&subtab=Privacy)

Here’s a video walking you through the editor.  
[https://youtu.be/hmlmJtvvKd0](https://youtu.be/hmlmJtvvKd0)

Demo here: [Your Bubble app](https://knowcode-tech.bubbleapps.io/version-test/anonymous_token?code=123)

---

<div class="post-metadata">

**Author:** ![augusto1](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@augusto1](https://forum.bubble.io/u/augusto1)\
**Post date:** [February 21, 2022, 8:11am UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/15 "2022-02-21T08:11:21Z")

</div>

[lindsay\_knowcode](http://forum.bubble.io/u/lindsay_knowcode), finally working, great solution… ! No user creation… So 2 good solutions in a few hours ! 😄

A small issue though…  
Sometimes I’ve to load twice…  
It loads previous token instead (only in Repeating Group…), so an odd behaviour…

Have a try, click in the links many times, and see for youself:

> **[Bubble - Visual Programming](https://privacytest1.bubbleapps.io/version-test?code=123)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

---

<div class="post-metadata">

**Author:** ![augusto1](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@augusto1](https://forum.bubble.io/u/augusto1)\
**Post date:** [February 21, 2022, 2:32pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/16 "2022-02-21T14:32:09Z")

</div>

Is is loading Repeating Group before making changes to Current User…  
That’s why I need a refresh…  
Is there a way to solve that, without tricks? 😆

---

<div class="post-metadata">

**Author:** ![lindsay\_knowcode](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/lindsay_knowcode/32/92967_2.png) [@lindsay\_knowcode](https://forum.bubble.io/u/lindsay_knowcode)\
**Post date:** [February 21, 2022, 8:59pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/17 "2022-02-21T20:59:28Z")

</div>

Yes that timing issue of the User change to the RG change is just the way Bubble works. I’d say in the “real” world for validating anonymous tokens, you would not rely on a RG updating as per my example but update a custom state to change the UI, show hide/some group, redirect the User to another Bubble page, or some explicit workflow action to change the UI state.

I used a RG in the example to prove to myself that the Privacy Rules worked 🙂 not because I thought that was a good way to signal in the UI that the token was valid.

---

<div class="post-metadata">

**Author:** ![augusto1](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@augusto1](https://forum.bubble.io/u/augusto1)\
**Post date:** [February 21, 2022, 11:11pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/18 "2022-02-21T23:11:57Z")

</div>

Excellent !  
A pleasure to talk to you.  
Regards!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [May 1, 2022, 6:31pm UTC](https://forum.bubble.io/t/slug-as-privacy-rule-no-login-slug-as-a-token/192702/19 "2022-05-01T18:31:38Z")

</div>

This topic was automatically closed after 70 days. New replies are no longer allowed.
