From patchwork Mon Oct 23 21:08:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 1484 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id DE34560D94 for ; Mon, 23 Oct 2017 12:08:19 +0200 (CEST) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id DBAED2174; Mon, 23 Oct 2017 12:08:18 +0200 (CEST) Received: from bockland.local.familyschlag (unknown [10.172.1.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 5F8E32172; Mon, 23 Oct 2017 12:08:16 +0200 (CEST) From: Jonatan Schlag To: pakfire@lists.ipfire.org Subject: [PATCH] Allow it to create a user without specifying a password Date: Mon, 23 Oct 2017 12:08:12 +0200 Message-Id: <20171023100812.15335-1-jonatan.schlag@ipfire.org> X-Mailer: git-send-email 2.11.0 X-BeenThere: pakfire@lists.ipfire.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Mailinglist for the Pakfire Build System." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: pakfire-bounces@lists.ipfire.org Sender: "Pakfire" This is useful when we implement authentication against LDAP. Fixes: #11517 Signed-off-by: Jonatan Schlag --- src/buildservice/users.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/buildservice/users.py b/src/buildservice/users.py index 8af92d7..50c44af 100644 --- a/src/buildservice/users.py +++ b/src/buildservice/users.py @@ -132,7 +132,9 @@ class Users(base.Object): return user def register(self, name, password, email, realname, locale=None): - return User.new(self.pakfire, name, password, email, realname, locale) + user = User.new(self.pakfire, name, email, realname, locale) + user.passphrase = password + return user def name_is_used(self, name): users = self.db.query("SELECT id FROM users WHERE name = %s", name) @@ -241,9 +243,9 @@ class User(base.Object): return cmp(self.realname, other.realname) @classmethod - def new(cls, pakfire, name, passphrase, email, realname, locale=None): - id = pakfire.db.execute("INSERT INTO users(name, passphrase, realname) \ - VALUES(%s, %s, %s)", name, generate_password_hash(passphrase), realname) + def new(cls, pakfire, name , email, realname, locale=None): + id = pakfire.db.execute("INSERT INTO users(name, realname) \ + VALUES(%s, %s)", name, realname) # Add email address. pakfire.db.execute("INSERT INTO users_emails(user_id, email, primary) \