cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jupyter123
Helper IV
Helper IV

Displaying User Details in top right corner

I have a created a login page which contains username, password and a sign in button.

So whenever the user signs in, he will be navigated to next page , only if the username and password matches the data in sharepoint list.

So, once the user is in next page, i should display the username in top right corner. Like Welcome User XXX!

So, how do i do that?

2 ACCEPTED SOLUTIONS

Accepted Solutions
RusselThomas
Microsoft
Microsoft

Hi @Jupyter123 ,

If the person using the app is the authenticated logged-in user of the app, then @WarrenBelz is 100% correct, PowerApps will retain some basic user info you can retrieve with the User() function.

This does make me wonder though why you would be storing separate usernames and passwords in SharePoint if you can just use the authenticated user credentials used to run the app in the first place...

 

If, instead, you're running the app in a Kiosk mode where many users might use the same app instance, while the app itself is logged in as a different user, then the User() function will always only return the logged in user credential info, which may not be associated with the user you've saved in SharePoint.

 

If this is the case, then presumably you're at some point asking these users to specify a username and password to "register" on this app - where you save their usernames and passwords for logging in later.  If so, then you would also need to ask them for their name at this point, so you can save it back to your sharepoint list as well - then when they login you can fetch it and use it later again in a Text label.

 

Just please note, storing usernames and plaintext passwords in SPO is not very secure.  There are ways to beef up the security a bit, but at the very least you should consider 1-way hashing your passwords and incorporating this into your login validation process.  Regardless of any of these, it's still not as secure as using authentication tokens.  

 

Anyway, assuming your SPO list has the following columns;

username, password, name

your login button OnSelect: property might look something like this;

Set(varUserRecord, {});
Set(varUserRecord, LookUp(MySPOList, username=usernameTextInput.Text && password=passwordTextInput.Text));
If(IsBlank(varUserRecord.ID), 
   Notify("Invalid username or password", NotificationType.Error, 3000),
   Notify("Successful Login", NotificationType.Success, 3000);Navigate(NextScreen, None)
)

Then on the next screen your text label Text: property would be

"Welcome User " & varUserRecord.name & "!"

Hope this helps,

RT

 

View solution in original post

MithaliGupta
Resolver IV
Resolver IV

If you take it as USER().Display Name//User().FullName it will help

View solution in original post

10 REPLIES 10
WarrenBelz
Super User
Super User

Hi @Jupyter123 ,

A Label with the Text of

"Welcome " & User().FullName

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

RusselThomas
Microsoft
Microsoft

Hi @Jupyter123 ,

If the person using the app is the authenticated logged-in user of the app, then @WarrenBelz is 100% correct, PowerApps will retain some basic user info you can retrieve with the User() function.

This does make me wonder though why you would be storing separate usernames and passwords in SharePoint if you can just use the authenticated user credentials used to run the app in the first place...

 

If, instead, you're running the app in a Kiosk mode where many users might use the same app instance, while the app itself is logged in as a different user, then the User() function will always only return the logged in user credential info, which may not be associated with the user you've saved in SharePoint.

 

If this is the case, then presumably you're at some point asking these users to specify a username and password to "register" on this app - where you save their usernames and passwords for logging in later.  If so, then you would also need to ask them for their name at this point, so you can save it back to your sharepoint list as well - then when they login you can fetch it and use it later again in a Text label.

 

Just please note, storing usernames and plaintext passwords in SPO is not very secure.  There are ways to beef up the security a bit, but at the very least you should consider 1-way hashing your passwords and incorporating this into your login validation process.  Regardless of any of these, it's still not as secure as using authentication tokens.  

 

Anyway, assuming your SPO list has the following columns;

username, password, name

your login button OnSelect: property might look something like this;

Set(varUserRecord, {});
Set(varUserRecord, LookUp(MySPOList, username=usernameTextInput.Text && password=passwordTextInput.Text));
If(IsBlank(varUserRecord.ID), 
   Notify("Invalid username or password", NotificationType.Error, 3000),
   Notify("Successful Login", NotificationType.Success, 3000);Navigate(NextScreen, None)
)

Then on the next screen your text label Text: property would be

"Welcome User " & varUserRecord.name & "!"

Hope this helps,

RT

 

thank you very much, your solution works 

would you think using database for storing username and password in backend is fine? 
what's your thoughts on this? @RusselThomas 

RusselThomas
Microsoft
Microsoft

Hi @Jupyter123 ,
It would be better than a SharePoint list, but I would still look into 1-way password hashing.  If the usernames are personally identifiable as well (like email addresses, phone numbers or actual name and surname) then there may be additional requirements from a protection of personal information perspective, depending on which country you're in.

 

1-way password hashing lets you store your passwords as hashes, which you get by running the password through an algorithm that 'scrambles' it - it will always come up with the same long complicated result when you hash the same thing - and they are traditionally difficult to 'unhash' - which is why it's called a one-way hash.

 

To use this in a password context, when the user registers with their password, you hash it and store the hash instead of the password.  To hash it, you would need to use an API, SQL or azure function or something similar, because PowerApps doesn't have a Hash function (Although there is an idea logged for it if you want to upvote).

 

Then, whenever a user logs in, you hash the password they enter into the password field, then compare the resulting hash with the hashes in the list/database.

 

This just makes it difficult for someone who has access or gains access to the list or database from seeing a whole bunch of readable passwords - instead they will see 'garbage' which they can't really use to login with.

Hope this helps,

RT

@RusselThomas @WarrenBelz Hi, so the above code that you sent , it actually works in power apps and i could able to display the user details in top right corner.

But, without writing that code, is it possible to do via power automate/power flow?

So in power automate, on selecting username and password,, that user details should be displayed on top and as well as it should get saved in share point list column field

is it possible to do that via power automate?

If yes, may i know how to do that?

RusselThomas
Microsoft
Microsoft

Hi @Jupyter123 ,

Probably a question the Power Automate forum people might be better at answering, but I can say it largely depends on which user profile you're looking for and how you're triggering the flow.

 

For example, if the flow is triggered by SharePoint on a new item or item modified, you have dynamic properties (User Name, User Email, User ID) that you can access from the trigger outputs to use in your flow.  If you use the Office365Users connector in Power Automate it also has a GetMyProfile function which should return the profile of the current user, and from there you can get all the details you need - depending on whether the user context you're referring to is actually the user running the flow.

 

But like the previous answer in this thred - If it's information that is stored in a list somewhere (like a user name field you created in your SPO list), then you need to go and fetch that information using the SPO connector and Get Items function in Power Automate...

 

It might help if you gave a little more detail about what experience you're trying to create for the user in order for us to provide the right advice here...

 

Kind regards,

RT

Hi again @RusselThomas 
Thank you for the quick response.

So let me explain what i wanted to do actuallly
First off, I have created a login page which contains username and password (That's page 1 in that application)

Secondly, The username and password is saved in a sharepoint list which is used to authenticate username and password. [Later, i will add 1 password hashing]

So after the user logins , it will navigate to second page. and in second page, i want that user name to be displayed in top right corner.

You've already sent me the code to display the user details in top right corner but that was did through power apps formula code.

Is it possible to do the same in power automate?

 

if yes, pls guide me in detail how to do that.

RusselThomas
Microsoft
Microsoft

Hi @Jupyter123 ,

So you have the Power Apps login and display name piece as part of the user interface - Power Automate is a logic app, so it will do things like automate stuff in the background, fetching data, running tasks etc.....  The user will never actually "see" Power Automate.  So how did you see Power Automate working as part of this user experience?

Kind regards,

RT

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,438)