cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Water
Regular Visitor

Custom Login Screen before accessing other screens

Is it possible to create a Login Screen that takes a Username and Password and authenticates against where the username and passwords are stored?

 

Then if validation is successful, it stores the identity of the user that can be used for accountability purposes (ex. every form user submits also passes the username of the submitter).

 

Not sure yet where the data will be stored, but any ideas would be great.

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Meneghino
Community Champion
Community Champion

Hi @Water

Yes, it is easily possible and there a number of ways to realise this.

 

Here is an idea assuming that username and passwords are stored in a table/data source called Users.

1) On your landing screen place two text inputs and a button

2) Set the OnSelect property of the button to the following

ClearCollect(CurrentUser, Filter(Users, UserName = TextInputUserName.Text, Password = TextInputPassword.Text));
If(CountRows(CurrentUser)=1,
     Navigate(MyNextScreen, None),
     Navigate(LoginFailedScreen, None)
)

If the login is successful then the user identity will be stored as the only record of the collection CurrentUser so that you can use this data anywhere in the app.

If the login has failed, you navigate to a LoginFailedScreen that you can create with the appropriate message.

 

Hope this helps.

View solution in original post

12 REPLIES 12
Meneghino
Community Champion
Community Champion

Hi @Water

Yes, it is easily possible and there a number of ways to realise this.

 

Here is an idea assuming that username and passwords are stored in a table/data source called Users.

1) On your landing screen place two text inputs and a button

2) Set the OnSelect property of the button to the following

ClearCollect(CurrentUser, Filter(Users, UserName = TextInputUserName.Text, Password = TextInputPassword.Text));
If(CountRows(CurrentUser)=1,
     Navigate(MyNextScreen, None),
     Navigate(LoginFailedScreen, None)
)

If the login is successful then the user identity will be stored as the only record of the collection CurrentUser so that you can use this data anywhere in the app.

If the login has failed, you navigate to a LoginFailedScreen that you can create with the appropriate message.

 

Hope this helps.

View solution in original post

Thanks Meneghino! Glad to know that there is a way.

 

I am a bit hesitant about storing passwords as plain-text though. What if I want to hash the stored password on the source? Do I need to create my own webservice already or in PowerApps, can I define the hashing algorithm (so I can compare with the one in the DB)?

Meneghino
Community Champion
Community Champion

Hi @Water

I think there is no easy way to define a hashing algorithm in PowerApps except using the standard functions, so probably webservice?

Meneghino
Community Champion
Community Champion

By the way, I never use this method and rely on the Office365 authentication.  Much more robust in my view.

Thanks Meneghino. I agree that O365 auth is most robust and safe, but we want to share this app with people who doesn't have O365 accounts as well and maybe still have some accountability.

 

Username and password is ideal, but can probably make do with just ID + Name as identifiers and works similarly with what you suggested.

 

Thank you for the help!

Meneghino
Community Champion
Community Champion

I believe that you cannot share apps outside your organisation/domain.  You can create free accounts in your Office 365 domain to give access to the apps.

gaba94
Frequent Visitor

Dear @Meneghino,

 

I want to create a new seperate login which is in the same powerapps. Basically, I am developing a voting apps. This apps is shared with 7 people to vote. There will be 2 Navigate button (you can refer to attachment "BUTTON PREVIEW.JPG"). 

 

So, what i want to do is I want to add one more button which is the fuction is to sent  (CONGRATULATION) via email to other people in organization. But the problem is, I dont know what formula should I use. So I want to know how am i gonna secure the page by making a seperate login password in this powerapps.

 

What I Want To Create :

 

*I want to add Staff ID and Password. (you can refer to attachment "login page.JPG")

 Then, the person who knows the password will only have access to that page.

 

*The person who have the access can Shared (congratulation) via email by clicking the sent button. (you can refer to attachment    below "email page.JPG")

 

 

I am still new with powerapps, hope you can helps to solve the problems.

 

Thanks,

gaba94 

 

Meneghino
Community Champion
Community Champion

HI @gaba94

I would strongly recommend relying on the Office 365 identities in managing permissions within your app.

Is there any reason you cannot do that?

Anonymous
Not applicable

Hi @Meneghino,

 

I know this thread was a while back but it seems your solution no longer works.

 

I've had to slightly change the syntax of your original code as i kept getting an "Invalid name" error. However now, using correct details from a database returns false instead being allowed through. E.G If a username was UN and their password was PW, the code doesn't allow them through.

 

This is what i have in my app (basically what you wrote adapted to my needs)

 

ClearCollect(CurrentUser, Filter(ManagerDatabase, TextInputUserName.Text = "UserName" , Password = TextInputPassword.Text));
If(CountRows(CurrentUser)=1,
     Navigate(ManagerHomeScreen, None),
     Set(correct, false)
)

Please can you help me as to why this isn't working?

 

Kind regards,

Colleen

 

EDIT:

I realised that perhaps i should change the first line to 

ClearCollect(CurrentUser, Filter(ManagerDatabase, TextInputUserName.Text = "UserName" , TextInputPassword.Text = "Password"))

Yet i am still erroring. I also tried changing the names in the database so that UN would become "UN" but nothing is seeming to fix this

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,613)