❔ Login module and signup

Dear C# expert, I am trying to build a program on login module and signup using Username: Joe.Doe and Password: Password123 as testing data for login attempts. They may be initialized as a verified dummy user in the Bank object. And the method for signup will ask the user to register him/herself by providing personal information in the form field or attributes which are Username, Email, Age, Phone, and Password.
8 Replies
Angius
Angius12mo ago
Your code is cut off Also, what are the errors?
Bubble Guppies
Bubble Guppies12mo ago
Bubble Guppies
Bubble Guppies12mo ago
This are the errors
Angius
Angius12mo ago
They're pretty clear Most of them would disappear if half of your code wasn't removed How did that happen anyway?
Bubble Guppies
Bubble Guppies12mo ago
I wanted to use private Dictionary<string, string> users = new Dictionary<string, string>(); because I don't really understand how to go further with this code because our lecturer hasn't finished teaching the topic required for this assignment. And she said we shouldn't use code that she hasn't taught yet which makes this much hard for us to find another way. I just need help with my code to accomplish this task. I would be really grateful if you can help me.
Angius
Angius12mo ago
If you want to use a dictionary, sure, I guess you can do that
class Bank
{
private Dictionary<string, string> _users = new(){
// ["name"] = "password"
["John"] = "hunter2",
["Mary"] = "zaq1@WSX"
}

public bool CheckPassword(string name, string password)
{
if (_users.TryGetValue(name, out var pass))
{
return pass == password;
}
}
}
class Bank
{
private Dictionary<string, string> _users = new(){
// ["name"] = "password"
["John"] = "hunter2",
["Mary"] = "zaq1@WSX"
}

public bool CheckPassword(string name, string password)
{
if (_users.TryGetValue(name, out var pass))
{
return pass == password;
}
}
}
Something like this would let you use CheckPassword() method to see if a given user exists, and if the password entered is the same as the password saved in the dictionary
Bubble Guppies
Bubble Guppies12mo ago
Okay, thanks for your help.
Accord
Accord12mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts