def post(self): data = postData() if 'nickname' in data.keys() and 'email' in data.keys() and 'password' in data.keys(): from util.password import hash_password password= hash_password(data['password']) return doIt(insertUser(nickname=data['nickname'],email=data['email'], password=password) ) #return doIt(insertUser(nickname=data['nickname'],email=data['email'], password=data['password']) ) else: return json.dumps({"status":"fail1"})
def _add_user_hard(self, username, password): # type: (unicode, unicode) -> User points = 0 empty_buf = buffer(intbitset().fastdump()) self.db.cursor.execute( 'INSERT INTO users VALUES (NULL, ?, ?, ?, ?, ?)', [username, hash_password(password), points, empty_buf, empty_buf]) user_id = self.db.cursor.lastrowid self.commit() return User(user_id, username, points, intbitset(), intbitset())
def update_password(self, user, password): # type: (User, unicode) -> None """Update password to `password` for `user`.""" self.db.cursor.execute('UPDATE users SET password = ? WHERE id = ?', [hash_password(password), user.id]) self.commit()
def test_check_password_correct(self): self.assertTrue(check_password("password", hash_password("password")))
def test_hash_password(self): self.assertNotEqual("password", hash_password("password"))
def test_check_password_incorrect(self): self.assertFalse( check_password("not_password", hash_password("password")))
def update_password(self, new_password): self.password = hash_password(new_password)
def __init__(self, email, password): self.email = email self.password = hash_password(password)