This week —11 July to 17 July — was the fifth week of Google Summer of Code (GSoC) with CHAOSS. If you want to read my daily updates, I blog them in my GSoC tracker👩💻
TL;DR
adduser(username) method implemented for a given argument username and email.
What did I do this week?
This week was focused on some final features for the adduser CLI.
Add user subcommand CLI by Priya730 · Pull Request #1912 · chaoss/augur
*Signed-off-by: Priya Srivastava shivikapriya730@gmail.com This is work in progress Description Progress till now: Add…*github.com
The To Do’s of the week were:
avoid duplicates (Each user should have a unique username and email)
fix password hashing
Added generate password hash
changed bold output
As I was coding the above features, I thought of some possibilities:
email argument option update
validate email address
use a different model for admin, will be easy to differentiate between user and admin
Important Fix of the week:
- changes need to be made in multicommad.py for command to access the method. [Fixed]
Did I get stuck anywhere?
email validation to ensure that the entered argument is an email.
bycrypt password (sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) NOT NULL constraint failed: user.password_hash [SQL: INSERT INTO user (username, email, password_hash, admin, public_id) VALUES (?, ?, ?, ?, ?)])
Ideas and possibilities:
- validate username
username = field.data
if len(username) < 3:
raise ValidationError(
_('Username must be at least 3 characters long'))
valid_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._'
chars = list(username)
for char in chars:
if char not in valid_chars:
raise ValidationError(
_("Username may only contain letters, numbers, '-', '.' and '_'"))
- validate password (Ensure that passwords have at least 6 characters with one lowercase letter, one uppercase letter and one number.)
password = list(field.data)
password_length = len(password)
lowers = uppers = digits = 0
for ch in password:
if ch.islower(): lowers += 1
if ch.isupper(): uppers += 1
if ch.isdigit(): digits += 1
is_valid = password_length >= 6 and lowers and uppers and digits
if not is_valid:
raise ValidationError(
_('Password must have at least 6 characters with one lowercase letter, one uppercase letter and one number'))
Questions:
UserMixin benefits? will it help me in authorisation?
Flask-Login instead of Flask-User grrr. What’s the difference between the two. They seem almost identical.
Not able to find out the difference and decide which one to use.
Plus, usermanager (flask-user) is giving me errors (a lot of them!)
Random:
- Learnt more about good commit messages. ;)
What is coming up next?
I’ll make some final commits and once the PR is approved by my mentor, I’ll move on to the next tasks.
Until next time…