-
Notifications
You must be signed in to change notification settings - Fork 2
Add users #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
herrone
wants to merge
4
commits into
develop
Choose a base branch
from
AddUsers
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add users #190
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| using SQLite; | ||
| using System.ComponentModel; | ||
|
|
||
| namespace UndacApp.Models | ||
| { | ||
| public class User : AModel | ||
| { | ||
| private string _name; | ||
| public string Name | ||
| { | ||
| get => _name; | ||
| set => SetField(ref _name, value); | ||
| } | ||
|
|
||
| private string _email; | ||
| public string Email | ||
| { | ||
| get => _email; | ||
| set => SetField(ref _email, value); | ||
| } | ||
|
|
||
| private string _accessLevel; | ||
| public string AccessLevel | ||
| { | ||
| get => _accessLevel; | ||
| set => SetField(ref _accessLevel, value); | ||
| } | ||
|
|
||
| private bool _employed = true; | ||
| public bool Employed | ||
| { | ||
| get => _employed; | ||
| set => SetField(ref _employed, value); | ||
| } | ||
|
|
||
| private string _role; | ||
| public string Role | ||
| { | ||
| get => _role; | ||
| set => SetField(ref _role, value); | ||
| } | ||
|
|
||
| private string _team; | ||
| public string Team | ||
| { | ||
| get => _team; | ||
| set => SetField(ref _team, value); | ||
| } | ||
|
|
||
| private string _password; | ||
| public string Password | ||
| { | ||
| get => _password; | ||
| set => SetField(ref _password, value); | ||
| } | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| using UndacApp.Models; | ||
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace UndacApp.Services | ||
| { | ||
| public interface IUsersService : IService<User> | ||
| { | ||
| // Define additional methods specific to user management if needed | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| using UndacApp.Models; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace UndacApp.Services | ||
| { | ||
| public class UsersService : AService<User>, IUsersService | ||
| { | ||
| public UsersService() : base() | ||
| { | ||
| // Additional initialization if required | ||
| } | ||
|
|
||
| // Implement any additional methods specific to the User entity | ||
| // For now, all basic CRUD operations are inherited from AService<User> | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| using System; | ||
| using System.Security.Cryptography; | ||
| using System.Text; | ||
|
|
||
| public static class PasswordHasher | ||
| { | ||
| public static string HashPassword(string password) | ||
| { | ||
| using (var sha256 = SHA256.Create()) | ||
| { | ||
| var hashedBytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(password)); | ||
| return Convert.ToBase64String(hashedBytes); | ||
| } | ||
| } | ||
|
|
||
| public static bool VerifyPassword(string enteredPassword, string storedHash) | ||
| { | ||
| string enteredHash = HashPassword(enteredPassword); | ||
| return enteredHash == storedHash; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="UndacApp.Views.UsersPage" | ||
| Title="User Management"> | ||
|
|
||
| <ScrollView> | ||
| <VerticalStackLayout Spacing="10" Margin="5"> | ||
| <!-- Login Section --> | ||
| <VerticalStackLayout Spacing="10"> | ||
| <Entry x:Name="txtLoginEmail" Placeholder="Email"/> | ||
| <Entry x:Name="txtLoginPassword" Placeholder="Password" IsPassword="True"/> | ||
| <Button Text="Login" Clicked="LoginButton_Clicked"/> | ||
| </VerticalStackLayout> | ||
|
|
||
| <!-- User Management Section (Initially Hidden) --> | ||
| <StackLayout x:Name="userManagementSection" IsVisible="False"> | ||
| <!-- User Addition Form --> | ||
| <VerticalStackLayout Spacing="10"> | ||
| <Entry x:Name="txtName" Placeholder="Name"/> | ||
| <Entry x:Name="txtEmail" Placeholder="Email"/> | ||
| <Entry x:Name="txtPassword" Placeholder="Password" IsPassword="True"/> | ||
| <Entry x:Name="txtTeam" Placeholder="Team"/> | ||
| <Picker x:Name="pickerRole" Title="Role"/> | ||
| <Picker x:Name="pickerAccessLevel" Title="Access Level"/> | ||
| <Button x:Name="AddUserButton" Text="Add User" Clicked="AddUserButton_Clicked"/> | ||
| </VerticalStackLayout> | ||
|
|
||
| <!-- User List and Selection --> | ||
| <ListView x:Name="listViewUsers" ItemSelected="OnUserSelected"> | ||
| <ListView.ItemTemplate> | ||
| <DataTemplate> | ||
| <TextCell Text="{Binding Name}" Detail="{Binding Email}" /> | ||
| </DataTemplate> | ||
| </ListView.ItemTemplate> | ||
| </ListView> | ||
|
|
||
| <!-- Edit and Delete Buttons --> | ||
| <StackLayout Orientation="Horizontal"> | ||
| <Button x:Name="btnEdit" Text="Edit" Clicked="EditUserButton_Clicked" IsEnabled="False"/> | ||
| <Button x:Name="btnDelete" Text="Delete" Clicked="DeleteUserButton_Clicked" IsEnabled="False"/> | ||
| </StackLayout> | ||
| </StackLayout> | ||
| </VerticalStackLayout> | ||
| </ScrollView> | ||
| </ContentPage> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job on password hashing!