Allow it to create a user without specifying a password

Message ID 20171023100812.15335-1-jonatan.schlag@ipfire.org
State New
Headers show
Series
  • Allow it to create a user without specifying a password
Related show

Commit Message

Jonatan Schlag Oct. 23, 2017, 9:08 p.m. UTC
This is useful when we implement authentication against LDAP.

Fixes: #11517

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
 src/buildservice/users.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Patch

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) \