How to get username of user accessing react web app - reactjs

I'm building a react web app that's going to be used internally. Is there a way to get the user's LAN ID? Similar to using this in .NET System.Security.Principal.WindowsIdentity.GetCurrent().Name
Is there a way to do this in my react home page?

Related

User Authentication and Authorization in React JS App & .NET Web API

Looking for guidance on how to authenticate & authorize users in React App.
We have existing .NET MVC & .NET core web apps from which user will try to navigate to a new app that's being developed using React JS & .NET Core Web API.
When we redirect between apps, we usually pass some user claims like session id/username from the parent app.
So, when an user tries to navigate from an existing MVC app using a button/link click, how to validate the user and redirect to REACT APP HOME PAGE in React App -> startup.cs ?
If user has view permissions to the requested page, system should redirect to the respective page else to display the access denied page.
This React JS app doesn't have any roles based authorization and its based on users permissions settings for each in backend (SQL SERVER).
Please provide your valuable suggestions.

Setup a hybrid structure of MVC and React App

I'm familiar with the .Net and React applications individually. What I want to do is to create a hybrid app of MVC and React for SaaS. Below are the details,
.NET MVC application for our website (can't create this in react as
it is a website and intended to use for google crawl, SEO, and all)
Once users log in using the MVC application LOGIN form, I want to redirect
them to ReactApp which is basically a portion after login
I already have a website built using MVC. Now want to load React application after successful login
Note: This needs to be run under the same domain. No redirection to sub-domain or so. Although, we can have an additional paths like /user
Questions:
Is it possible to traverse users between both applications?
Is it possible to manage the same session between the two?

Authentication of React native app with express js back end

I have developed Angular, express js web application with JWT authentication. Now I need to develop react native mobile app for the same purpose as a web application. How can I add authentication for react native app. should it need to use JWT for the react native app or are there any other authentication techniques for the mobile application. I'm new to react native as well as mobile app development. Give me some recommended guides for react native and express js back-end development. Both web application and mobile application has the same database implemented using MSSQL.
You can of course use the JWT strategy.
I suggest you to use the AsyncStorage to store your token or any other data.
https://reactnative.dev/docs/asyncstorage
For the authentication you could create an AuthenticationContext where to provide all the functions and logic you need for the authentication.
Inside the context you could have function to login and to logout, a function to store the user in the AsyncStorage, a function to remove the user from the AsyncStorage, a function to determine whether the user is authenticated and other logic according to your needs.

React js web application with Laravel passport Oauth2

I have a backend admin panel created in Laravel 8, and i have installed passport security also. Admin frontend is working on vuejs by using laravel frontend scaffolding.
I have another one website in react js and one mobile application in React Native. The api to the web and mobile application is from laravel admin application. So what my doubt is, when i use external react js application what are the grand types should i use for authorization. And how will i segregate api routes for login user data and common data to the external react application.
Anyone can help me to get into the track.
Thanks in advance.

IdentityServer4 with React

I am new to React, and developing a WebApp, which requires authenticating user via IdentityServer. So this is what i 've done so far :
Created a react web app using npx create-react-app.
Created a Security service using Identity server which renders my login page.
Where i am stuck :
Since i am planning to use redux in my react web app, shall i create a reducer/action for the login operation (i am planning to have them for other operations).
How to redirect user to the Authorize/Login page of security service and redirect back to my react app? (Can i use aurelia-oauth or some other plugin ?)
Things i have tried :
Have defined route for login page in react app (which will be discarded, since i am going to use login page of security service.
Tried making a get request for the login url of security service from react app. (Throws : TypeError: Object doesn't support property or method 'render' on react-dom.development.js)

Resources