Example #1
0
 public Session(User user, Guid authToken, DateTime expiry)
 {
     User = user;
     AuthToken = authToken;
     Start = DateTime.Now;
     Expiry = expiry;
 }
 public Session AuthenticateUser(User user, string passwordToTest)
 {
     if (user.Password == passwordToTest)
     {
         Session session = new Session(user, Guid.NewGuid(), DateTime.Now.AddMinutes(SESSION_DURATION));
         _sessions.Add(session.AuthToken, session);
         Logger.Storage.Debug("User '" + session.User.Username + "' successfully authenticated and given the authentication token: " + session.AuthToken);
         return session;
     }
     else
     {
         Logger.Storage.Warn("User '" + user + "' failed authentication due to an incorrect password.");
         return null;
     }
 }