Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public UserDto GetUser(string email) {
- if (!ValidationUtil.IsValidEmail(email))
- throw new ArgumentException("Must be a properly formatted email", nameof(email));
- UserDto toReturn = null;
- toReturn = Users?.FirstOrDefault(user => user?.Email == email);
- return toReturn;
- }
- public bool AreCredentialsValid(string email, string password) {
- bool toReturn = false;
- if (!ValidationUtil.IsValidEmail(email))
- throw new ArgumentException("Must be a properly formatted email", nameof(email));
- if (password == null)
- new ArgumentNullException(nameof(password));
- UserDto user = this.GetUser(email);
- if (user?.Email == email && user?.Password == password)
- toReturn = true;
- return toReturn;
- }
- public UserDto GetUserIfCredentialsAreValid(string email, string password) {
- UserDto toReturn = null;
- if (AreCredentialsValid(email, password))
- toReturn = GetUser(email);
- return toReturn;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement