mirror of
https://github.com/aaronleetw/Attendance.git
synced 2024-11-14 19:11:39 -08:00
password no shorter than 6
This commit is contained in:
parent
4f84122649
commit
f23d0a5057
1 changed files with 10 additions and 1 deletions
11
upload.py
11
upload.py
|
@ -37,6 +37,14 @@ def check_permission():
|
||||||
db.child("Users").child(session['uid']).child("showUpload").get(session['token']).val() == '1')
|
db.child("Users").child(session['uid']).child("showUpload").get(session['token']).val() == '1')
|
||||||
|
|
||||||
|
|
||||||
|
def addZeroesUntil(str, number):
|
||||||
|
if len(str) >= number:
|
||||||
|
return str
|
||||||
|
else:
|
||||||
|
str = str + '0'
|
||||||
|
return addZeroesUntil(str, number)
|
||||||
|
|
||||||
|
|
||||||
@upload.route('/upload/users', methods=['GET', 'POST'])
|
@upload.route('/upload/users', methods=['GET', 'POST'])
|
||||||
def upload_users():
|
def upload_users():
|
||||||
if ((not check_login_status()) and check_permission()):
|
if ((not check_login_status()) and check_permission()):
|
||||||
|
@ -50,8 +58,9 @@ def upload_users():
|
||||||
with open(filepath) as file:
|
with open(filepath) as file:
|
||||||
csv_dict = csv.DictReader(file)
|
csv_dict = csv.DictReader(file)
|
||||||
for row in csv_dict:
|
for row in csv_dict:
|
||||||
|
pwd = addZeroesUntil(row['password'], 6)
|
||||||
user = auth.create_user_with_email_and_password(
|
user = auth.create_user_with_email_and_password(
|
||||||
row['username'] + "@group-attendance.fhjh.tp.edu.tw", row['password'])
|
row['username'] + "@group-attendance.fhjh.tp.edu.tw", pwd)
|
||||||
db.child("Users").child(user['localId']).set({
|
db.child("Users").child(user['localId']).set({
|
||||||
'permission': 'realPerson',
|
'permission': 'realPerson',
|
||||||
'name': row['name'],
|
'name': row['name'],
|
||||||
|
|
Loading…
Reference in a new issue