mrlacey / MauiAppAccelerator

A Visual Studio extension to accelerate the creation of new .NET MAUI apps.
https://marketplace.visualstudio.com/items?itemName=MattLaceyLtd.MauiAppAccelerator
MIT License
307 stars 10 forks source link

Add Login Page #17

Open Tviljan opened 1 year ago

Tviljan commented 1 year ago

Is your feature request related to a problem? Please describe. Common feature when creating apps is to make user login before continuing to all/any app features

Describe the solution you'd like An optional login feature that would add a login template (custom/google/facebook/github) and where user is navigated to login page if not logged in. Login data could be stored to secure storage by default

Describe alternatives you've considered

Additional context

mrlacey commented 1 year ago

It's a great suggestion. It's also a very broad suggestion. It wi be necessary to refine exactly what should be output. It might also make sense to release this functionality in stages...

Tviljan commented 1 year ago

In my opinion the most simple login flow for app is simple check (in shell?) if user logged in and then either show the login screen or continue to main screen. Just store the login information to settings.

No real authentication is required. Just simples possible forced login,

Second, more complex possibility would use maybe google/apple/github login to the app, but not really that important in my opinion as it would be easy to add to the simple template.

juicebyjustin commented 1 year ago

What about a basic login page with view model that contains commands & properties for each button/input?

It's simple enough to make it, but if it came out of the box that'd be great.

As a reference; Chat GPT gave me with for WPF:

<Window x:Class="YourNamespace.LoginWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:YourNamespace"
        Title="Login" Height="300" Width="400">
    <Window.DataContext>
        <local:LoginViewModel />
    </Window.DataContext>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <TextBlock Text="Email" Grid.Row="0" Margin="10" />
        <TextBox Text="{Binding Email}" Grid.Row="1" Margin="10" Width="200" />
        <TextBlock Text="Password" Grid.Row="2" Margin="10" />
        <PasswordBox Password="{Binding Password}" Grid.Row="3" Margin="10" Width="200" />
        <Button Content="Sign In" Command="{Binding SignInCommand}" Grid.Row="4" Margin="10" Width="100" />
        <Button Content="Sign Up" Command="{Binding SignUpCommand}" Grid.Row="4" Margin="10,0,120,0" Width="100" />
        <Button Content="Forgot Password" Command="{Binding ForgotPasswordCommand}" Grid.Row="4" Margin="10,0,230,0" Width="100" />
    </Grid>
</Window>
mrlacey commented 1 year ago

Creating the UI isn't a challenge. (You've seen that even ChatGPT can get most of the way there--can you see the errors in what's generated?) The real challenge is in how it integrates with the rest of the generated app and also encourages best practices.

The first real challenge is in wanting to encourage developers towards industry best practices and recommendations. With that front of mind encouraging the direct entry of a password into a control where it can potentially be retrieved isn't desirable. And also not supporting any form of multi-factor authentication would be far from ideal.

Then I need to consider whether the app should enforce login before it's possible to access the rest of the app, or if the app can be used (in part or in full) when not logged in? Should it be a full page that is used for capturing the details, or should it be in a popup? or something else? And what about logging out? If adding a login mechanism, is an accompanying log-out option required too? If so, where should it go? and what should happen when logging out?

For all these scenarios, the "correct" answer will vary between applications. Obviously, in an ideal world, I'd add options to support all the possible options but that's not going to happen.

What I really need is to determine which options will bring the most value to the most people and then implement them in that order. Any thoughts?

Additionally, if you think that an example page that shows something like the code snippet above (with VM or code-behind) would also be useful, that would be easy to add.

Tviljan commented 1 year ago

I believe that for demoing purposes the most simple login page would be suitable. On startup a login screen is shown and user can just type in any username / password without actual logic for checking password. Or if something more advanced then when user chooses to add login feature a username and password (one or more) can be created (not sure how to deal with this. Maybe creating sqlite database?)