Beispiel #1
0
    def post(self, uid):
        user = User.get(uid)
        user["pwd"] = crypt.randpass()

        ldap = Ldap()
        ldap.reset_pwd(uid, user["pwd"])

        Mail().to(user)
        return self.succ()
Beispiel #2
0
    def put(self, uid, oldpass=None, newpass=None):
        if not oldpass:
            if not session.__contains__(USER_SESSION):
                raise ExceptionEx("未登录")

            if not User.get(session[USER_SESSION]["uid"])["is_admin"]:
                raise ExceptionEx("权限不足")

        if not uid or uid in ["*", u"*"]:
            return self.fail("无效的用户名")

        newpass = newpass if newpass else crypt.randpass()

        ldap = Ldap()
        if not ldap.reset_pwd(uid, newpass, oldpass):
            return self.fail()

        mail = Mail()
        mail.to(uid, newpass)

        return self.succ() if oldpass else self.succ(newpass)
Beispiel #3
0
    def put(self, uid, oldpass=None, newpass=None):
        if not oldpass:
            if not session.__contains__(USER_SESSION):
                raise ExceptionEx("未登录")

            if not User.get(session[USER_SESSION]["uid"])["is_admin"]:
                raise ExceptionEx("权限不足")

        if not uid or uid in ["*", u"*"]:
            return self.fail("无效的用户名")

        newpass = newpass if newpass else crypt.randpass()

        ldap = Ldap()
        if not ldap.reset_pwd(uid, newpass, oldpass):
            return self.fail()

        mail = Mail()
        mail.to(uid, newpass)

        return self.succ() if oldpass else self.succ(newpass)