jeudi 15 septembre 2022

How is different data shown to different users on the same URL?

I'm currently dealing with a situation where I need to display same URL to two types of users for viewing different data on the URL. Here is the background - Initially we had two different URLs for Metrics of type 1 and Metrics of type 2. So, in order to display which URL to which user we simply had an if condition something like this-

<%= if User1? %>
DISPLAY URL A
<%=end%>
<%= if User2? %>
DISPLAY URL B
<%=end%>

Later situation - For some reason the content(Basically metrics here) from URL B have been moved to URL A now (which is both types of metrics are present in single link here) Problem - Now we want to present only single URL to both types of users 1&2. However, when USER 1 is accessing he should be able to view all types of metrics in the URL. But when USER 2 is viewing the URL he should not view a particular metric (lets say type 2) but should see all the rest. So, in a nut shell we need to provide same URL for both users but they have to view different content and this has to be achieved with a simple IF statement something like -

<%= if User1? %>
<%= if User2? %>
DISPLAY URL A and block the content of metric type 2.
<end>
Display URL A with all metrics
<%=end%>

P.S - we have two types of metrics now in the consolidated link and both of them have different code-files from where they are fetching the code. I'm assuming if we can block accessing a file which has metric type 2 with an if condition then might solve problem. But can someone help me with this please ? Thank you!

My question - Can someone translate this pseudo code to actual code that works? Would be really really helpful.

Aucun commentaire:

Enregistrer un commentaire