示例#1
0
 public static Session MakeSecurityOverride()
 {
     Session s = new Session(new Security.User("System", null, "system", null, null, null, null, true),
         Guid.Empty, DateTime.Now.AddMinutes(15));
     s.IsSecurityOverride = true;
     return s;
 }
 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;
     }
 }