In an ASP.NEt MVC application, how is it possible to display some conditional data to a layout page?
My application allows a user with a role of "Admin" to view the other user's pages and data from the same application. When the Admin views the pages of another user he/she needs to see the information of the user like his name/role/etc whose data he/she is viewing ( this information comes from the DB) . This info needs to be shown in all the pages when an Admin User is logged in and ONLY when an ADmin is logged in. i.e, if a user who is not Admin enters these details should not be shown as it is not relevant.
The issue iam facing in my attempts is that the Admin user does not login to the user's page, instead I have to achieve this feature of switching to the users view by clicking on a list/grid of users. This takes me to the home page of the user (and i get the inforamtion displayed since i set it in viwbag) .Question is, how do i set this value in the subsequent user pages of this session. Trying to avoid filling this viewbag value in every controller/action.
Please help!
PS: The information that needs to be displayed in the layout is based on the user's ID that the Admin selects from the grid. It commes from the DB.
You could write the user id to a cookie and use a action filter to check for this cookie on requests done by the admin user
Related
I have develop LWC component which is normally used by normal users. In that lightning web component button is there as below.
<lightning-button slot="actions" label="Deactivate" onclick={DeactivateProcess}>
</lightning-button>
The above button should be only be show to System Admin Profile and Business Admin Profile. How to show the button only to those two Profiles without using record types or different page layouts?
I think this is not a good idea to get current user profile from lwc. Because User and Profile are two different object in Salesforce. You can only get user profile id by import it.
import PROFILE_ID from '#salesforce/schema/User.ProfileId';
Try to use apex and soql query for getting current user profile.
I am currently using JSON Web Token to authenticate every page of my website except homepage. The idea is to generate token on login/registration with the user's MongoDB id and save that into cookies. Then whenever user tries to open any page, first token will be decoded and then id will be matched with the database records to verify that the correct user is trying to access page.
I haven't launched the website yet. My question is, is it a good practice to access database before every page loads for user or will it slow down my website once more users start coming on website?
We are creating a back end admin system and want to allow users in roles such as finance and membership to have access to certain areas. Ideally we would like to show only areas that you have access to in the navigation.
Using umbraco 4.7+ and razor. We are using the Microsoft role provider.
I was wondering if anyone knows how I could access the currently logged in users role?
DynamicNode has two methods that will be your friends here, HasAccess() and IsProtected(). Here's an example of how to filter and show nodes that the user only has access to. Here's another one.
Using those methods you shouldn't need to have to get the roles of the currently logged in user, but that's not hard to do as well. Roles.GetRolesForUser() returns an array of the currently logged in user's roles. For more information, refer to the documentation.
I would like to recover the non-public information to a facebook page for an application "desktop" in C # and I do not know how. Do I have to go through a Facebook application that the user allow or do I get the Facebook user to have a access_token and display the page based on this one? FYI I use graph (and a JSON) that I get, I picked up this version as the "public" group:
https://graph.facebook.com/283774678311430
Do I have to go through a Facebook application that the user allow
Yes, you need an application to let the user give access to view the page or have the page owner give access
do I get the Facebook user to have a access_token and display the page based on this one?
Same answer, use the page owner as the user call /me/accounts and grab the page access token.
I have a simple product catalogue for businesses. There is a catalogue's management interface for adding products. Each business has a unique domain name where all its products are listed.
I would like to extend catagloue's functionality and allow businesses to have their products listed on facebook.
Functionality of the facebook application:
- Each business can install application from catalogue's management interface (I would like to have a button that opens facebook in a new window and prompts user to authorize access to one of user's existing Facebook Pages)
- installing application adds a Tab on selected Facebook Page,
- by clicking on a Tab visitor of the Facebook Page is presented with a list of products specific for this business. Data for that page is dynamic and can be accessed with a REST call and presented as json or html.
We would like each business that have a product catalogue with us to install application and have it automatically configured to use specific domain name when requesting product data.
Is it all technically possible? Could you point me into the right direction on how to
- install application from external website
- configure that application with a parameter (perhaps passed in url when requesting application installation)
- automatically add Page Tab for this application
Cheers,
Michal
Yes it is possible. But it'll be a little different from what you are thinking, i guess.
I recently implemented code to add a tab to a page programmatically, it is as follows(in PHP) :
$tabAdded=$facebook->api("/".$id."/tabs","post", array("access_token" => $access,
"app_id" => $fbconfig['appid']));
From the code we see that we need an app id, an access token, and the page id($id). $facebook is an instance of the FacebookPHPSDK.
So here's how we can get the three things in question:
First app id, you'll need to create a Facebook page tab app, select Page Tab in the app's Basic settings (where you can mention the page tab url. This url will have the content for a page tab.) You'll also need to enable website because you need to ask the user for necessary permissions (namely manage_pages). For your specific requirement you have to give the domain of the catalogue management app.
Second page id and access token, once you have manage_pages permission you can query the graph api to get the pages of the user using : api('me/accounts') this returns data with page name, page category, page id, page access token for all the user's pages.
#thaddeusmt has already mentioned that you can't create new applications, and need to use the same app, you have to read the signed request and get the page id, and serve content. All that will be left to do is link your customer domains to the correct page ids.
Hope this was useful.
You can install/uninstall (add/remove) application tabs to/from Pages using the Facebook API:
http://developers.facebook.com/docs/reference/api/page/#tabs
You cannot create new applications, however. So you will need to use the same application for each Page.
The way you can show different content for each Page in the Tab (using the same application) is by checking the Signed Request. This contains the ID of the Facebook Page. The code that serves up your application Tab can look at the Page ID and serve up the appropriate content for that Page.
I hope this helps get you on the trail. Good luck!
Yes it is possible.
It's a two way process
First you have to get page_access_token through graphAPI.
www.facebook.com/?fields=access_token
This will return Page_access_token.
Use page access token and use post method
www.facebook.com/yourpageid/tabs/
Post Parameters:
app_id= 'YourAppID'
access_token = 'access_token'
That way you can add your facebook app into facebookPage.