]> git.ipfire.org Git - ipfire.org.git/commitdiff
users: Move passwd handler from people
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Jun 2023 10:16:17 +0000 (10:16 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Jun 2023 10:16:17 +0000 (10:16 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/templates/users/passwd.html [moved from src/templates/people/passwd.html with 100% similarity]
src/web/__init__.py
src/web/people.py
src/web/users.py

index 8277a70636dc03c730f0ee8880dc919f1b292e50..2cfad43fac63cc6d4af6d47397a48a7335659d1e 100644 (file)
@@ -275,7 +275,6 @@ templates_people_DATA = \
        src/templates/people/call.html \
        src/templates/people/calls.html \
        src/templates/people/index.html \
-       src/templates/people/passwd.html \
        src/templates/people/sip.html \
        src/templates/people/subscribed.html \
        src/templates/people/unsubscribe.html \
@@ -309,6 +308,7 @@ templates_staticdir = $(templatesdir)/static
 
 templates_users_DATA = \
        src/templates/users/index.html \
+       src/templates/users/passwd.html \
        src/templates/users/show.html
 
 templates_usersdir = $(templatesdir)/users
index 91a8cdc23f10848edf549f99fd8b3c825de80479..92bb56fccd2f903bb40eac308c9ddf32927f8acc 100644 (file)
@@ -168,6 +168,7 @@ class Application(tornado.web.Application):
                        (r"/users", users.IndexHandler),
                        (r"/users/([a-z_][a-z0-9_-]{0,31})", users.ShowHandler),
                        (r"/users/([a-z_][a-z0-9_-]{0,31})\.jpg", users.AvatarHandler),
+                       (r"/users/([a-z_][a-z0-9_-]{0,31})/passwd", users.PasswdHandler),
 
                        # Static Pages
                        (r"/about",  StaticHandler, { "template" : "about.html" }),
@@ -319,7 +320,6 @@ class Application(tornado.web.Application):
                        (r"/users/([a-z_][a-z0-9_-]{0,31})/calls/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})", people.CallHandler),
                        (r"/users/([a-z_][a-z0-9_-]{0,31})/calls(?:/(\d{4}-\d{2}-\d{2}))?", people.CallsHandler),
                        (r"/users/([a-z_][a-z0-9_-]{0,31})/edit", people.UserEditHandler),
-                       (r"/users/([a-z_][a-z0-9_-]{0,31})/passwd", people.UserPasswdHandler),
                        (r"/users/([a-z_][a-z0-9_-]{0,31})/sip", people.SIPHandler),
 
                        # Promotional Consent Stuff
index 3502704ff341021acfcf810f891799b38bf6ba26..251e74dc6221fe77ee767593db9407a5b3085580 100644 (file)
@@ -160,53 +160,6 @@ class UserEditHandler(base.BaseHandler):
                self.redirect("/users/%s" % account.uid)
 
 
-class UserPasswdHandler(base.BaseHandler):
-       @tornado.web.authenticated
-       def get(self, uid):
-               account = self.backend.accounts.get_by_uid(uid)
-               if not account:
-                       raise tornado.web.HTTPError(404, "Could not find account %s" % uid)
-
-               # Check for permissions
-               if not account.can_be_managed_by(self.current_user):
-                       raise tornado.web.HTTPError(403, "%s cannot manage %s" % (self.current_user, account))
-
-               self.render("people/passwd.html", account=account)
-
-       @tornado.web.authenticated
-       def post(self, uid):
-               account = self.backend.accounts.get_by_uid(uid)
-               if not account:
-                       raise tornado.web.HTTPError(404, "Could not find account %s" % uid)
-
-               # Check for permissions
-               if not account.can_be_managed_by(self.current_user):
-                       raise tornado.web.HTTPError(403, "%s cannot manage %s" % (self.current_user, account))
-
-               # Get current password
-               password = self.get_argument("password")
-
-               # Get new password
-               password1 = self.get_argument("password1")
-               password2 = self.get_argument("password2")
-
-               # Passwords must match
-               if not password1 == password2:
-                       raise tornado.web.HTTPError(400, "Passwords do not match")
-
-               # XXX Check password complexity
-
-               # Check if old password matches
-               if not account.check_password(password):
-                       raise tornado.web.HTTPError(403, "Incorrect password for %s" % account)
-
-               # Save new password
-               account.passwd(password1)
-
-               # Redirect back to user's page
-               self.redirect("/users/%s" % account.uid)
-
-
 class AgentModule(ui_modules.UIModule):
        def render(self, account):
                return self.render_string("people/modules/agent.html", account=account)
index af34078bb823c75bed3d138ad56082fee3d8265a..89e2359debf76caeffe5db0b2b2e86bd4b0c03f0 100644 (file)
@@ -142,6 +142,53 @@ class AvatarHandler(base.BaseHandler):
                        return f.getvalue()
 
 
+class PasswdHandler(base.BaseHandler):
+       @tornado.web.authenticated
+       def get(self, uid):
+               account = self.backend.accounts.get_by_uid(uid)
+               if not account:
+                       raise tornado.web.HTTPError(404, "Could not find account %s" % uid)
+
+               # Check for permissions
+               if not account.can_be_managed_by(self.current_user):
+                       raise tornado.web.HTTPError(403, "%s cannot manage %s" % (self.current_user, account))
+
+               self.render("users/passwd.html", account=account)
+
+       @tornado.web.authenticated
+       def post(self, uid):
+               account = self.backend.accounts.get_by_uid(uid)
+               if not account:
+                       raise tornado.web.HTTPError(404, "Could not find account %s" % uid)
+
+               # Check for permissions
+               if not account.can_be_managed_by(self.current_user):
+                       raise tornado.web.HTTPError(403, "%s cannot manage %s" % (self.current_user, account))
+
+               # Get current password
+               password = self.get_argument("password")
+
+               # Get new password
+               password1 = self.get_argument("password1")
+               password2 = self.get_argument("password2")
+
+               # Passwords must match
+               if not password1 == password2:
+                       raise tornado.web.HTTPError(400, "Passwords do not match")
+
+               # XXX Check password complexity
+
+               # Check if old password matches
+               if not account.check_password(password):
+                       raise tornado.web.HTTPError(403, "Incorrect password for %s" % account)
+
+               # Save new password
+               account.passwd(password1)
+
+               # Redirect back to user's page
+               self.redirect("/users/%s" % account.uid)
+
+
 class GroupIndexHandler(base.BaseHandler):
        @tornado.web.authenticated
        def get(self):