aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Services/UserService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Timeline/Services/UserService.cs')
-rw-r--r--Timeline/Services/UserService.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/Timeline/Services/UserService.cs b/Timeline/Services/UserService.cs
new file mode 100644
index 00000000..b3d76e3e
--- /dev/null
+++ b/Timeline/Services/UserService.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Timeline.Entities;
+
+namespace Timeline.Services
+{
+ public interface IUserService
+ {
+ /// <summary>
+ /// Try to anthenticate with the given username and password.
+ /// </summary>
+ /// <param name="username">The username of the user to be anthenticated.</param>
+ /// <param name="password">The password of the user to be anthenticated.</param>
+ /// <returns><c>null</c> if anthentication failed.
+ /// An instance of <see cref="User"/> if anthentication succeeded.</returns>
+ User Authenticate(string username, string password);
+ }
+
+ public class UserService : IUserService
+ {
+ private readonly IList<User> _users = new List<User>{
+ new User { Id = 0, Username = "hello", Password = "crupest" },
+ new User { Id = 1, Username = "test", Password = "test"}
+ };
+
+ public User Authenticate(string username, string password)
+ {
+ return _users.FirstOrDefault(user => user.Username == username && user.Password == password);
+ }
+ }
+}