Get windows current loggedin user - angularjs

What is the simplest way to get the windows current logged-in username in client side running on chrome browser?
I need a short JS code example that retrieve only the username.

Related

How can I open a link in react web app without giving user name and password again?

I have a running react web application with protected routes. We are using JSON web tokens. We also using Redux saga. I want to provide a link and This need to be open in a new tab. But when the user logged in and click on the link, the link opens in a new tab but it asks user name and password again. I want to share the current state with the app in the new tab.
How are you storing the JWT? The most common way to do it is to store the JWT in cookies which automatically get sent on every request in the same domain. As long as the JWT is in a cookie, the cookie gets passed to the server, and the server checks for and uses the JWT payload, you should be able to open a new tab just fine.

angular ui-router skip login for authenticated user

i have an angularjs app, i am using cookie based authentication in this app. when i login with two different users in same browser window in different tabs my cookie gets override. For example i am logged in with a user 'A' in first tab of browser and i am logged in with a user 'B' in second tab of the same browser window. when i check the cookie in browser, i only see the information about last logged in user. and when i try to navigate through application with user 'A' i get wrong data.
my question is is there any way i can skip login screen if a user is already logged in my application? so that no other user can login within same browser?
i tried to use resolve:in AngularApp.config and tried to redirect already logged in user to /home but still i am unable to achieve it. any thoughts?
Once the login is completed you can save the status of the application in session storage. Then when you are initialising the application you can check the value exits in session storage or not and redirect user to different page depend on the value. Make sure you are removing the stored value in session storage when user logout from the application

How to open a different url with a new tab and automate login in an angular based app

I have an angular based app and I want to open another URL on a new tab from my app and automate a login. For example my app is www.myapp.com, and it will open www.anotherurl.com/login. Let's say I have both the username and password for www.anotherurl.com/login.
How can I automate the login by populating the form and do the login?
Is this something we can achieve from the client side? or this needs a server side implementation?
Or is this is even possible?
Update:
I have no control over www.anotherurl.com/login by the way. This is just another way of saying I want to open gmail.com with credentials and automate a login instead of me typing the username and password, and pushing the login button myself.
Thanks in advance for your thoughts.
you can send them along as query parameters, but if you are not using https then they will be sent in the clear. for example:
https://www.anotherurl.com/login?user=bob&pass=secret
then in your controller, if these query params are present then call a login method
also worth mentioning that even if its over https the password will be in the user's browser history and thats probably not a good thing either.

Refreshing in browser changes template in angularJS

I'm having a weird problem with my angular app. When the user is logged in and hits "refresh" in the browser, the app loads the log-in template which is part of the main index.html file. It does not, however, kill the user session, but the user can't get any where else in the app without re-authenticating. Can anyone offer advice?
When a user refreshes the browser, your entire angular application disappears and gets restarted. That's how SPAs ("Single Page Apps") work.
If you want to have the user not log in every time they do this, you have to save enough information in the browser itself to know that he or she has already logged in. You can do this by storing some information either in a cookie or HTML5 local storage, and checking to see if the login information is stored before you call your authentication service.
Also, if you use standard http BASIC authentication the browser itself will cache the authentication credentials.

Salesforce Oauth 2.0 Authorization screen

Using this guide as a reference, I've created a Remote Access application entry in my developer account.
I tried to play around with the Authorization screen that the user should see after navigating to this URL:
https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=[your_client_id]&redirect_uri=[your_redirect_uri]
When I fill in the right values and navigate to the URL, I am not taken to the screen that I expect to see, but rather the regular Salesforce login screen. If I enter credentials & log in, I get redirected to the 'redirect uri' that I set on the Remote Access screen. (i'm using google.com for now). What am I getting wrong?
The approval screen should appear once the user has logged in, is that not what you see ?

Resources