Beispiel #1
0
 def create(self, username=None, password=None):
     """Create a user."""
     infos = {}
     if username:
         infos["username"] = username
     if password:
         infos["password"] = ModUser.hash_password(password, "sha1")
     infos["salt"] = ModUser.generate_salt()
     user = ModUser(**infos)
     user = user.display_representation(["id", "username"])
     return self.render("auth.user.view", user=user)
Beispiel #2
0
 def create(self, username=None, password=None):
     """Create a user."""
     infos = {}
     if username:
         infos["username"] = username
     if password:
         infos["password"] = ModUser.hash_password(password, "sha1")
     infos["salt"] = ModUser.generate_salt()
     user = ModUser(**infos)
     user = user.display_representation(["id", "username"])
     return self.render("auth.user.view", user=user)
Beispiel #3
0
 def do_login(self, username=None, password=None):
     if not username or not password:
         return "Empty username or password."
     
     user = None
     for u in User.get_all():
         if u.username == username:
             user = u
             break
     
     if user is None:
         return "Invalid username."
     
     if user.check_password(password):
         self.server.services.authentication.authenticate(self.request, user)
         return "Logged in."
     else:
         return "Invalid password."
Beispiel #4
0
 def list(self):
     """Return the list of users."""
     return self.render("auth.user.list", users=ModUser.get_all())
Beispiel #5
0
 def list(self):
     """Return the list of users."""
     print(self.server.services.authentication.authenticated(self.request))
     return self.render("auth.user.list", users=ModUser.get_all())
Beispiel #6
0
 def list(self):
     """Return the list of users."""
     print(self.server.services.authentication.authenticated(self.request))
     return self.render("auth.user.list", users=ModUser.get_all())
Beispiel #7
0
 def list(self):
     """Return the list of users."""
     return self.render("auth.user.list", users=ModUser.get_all())