IsaacKerson commited on
Commit
940d4dd
1 Parent(s): e817f7f

insert members into users db

Browse files
Files changed (2) hide show
  1. pages/join.py +12 -4
  2. requirements.txt +1 -1
pages/join.py CHANGED
@@ -1,6 +1,6 @@
1
  import streamlit as st
 
2
  import sqlite3
3
- import random
4
  import datetime
5
 
6
  # Custom imports
@@ -35,7 +35,15 @@ def app():
35
 
36
  if submitted and password1.strip() != password2.strip():
37
  st.warning("The passwords do not match.")
38
- if user_name in usernames:
39
  st.warning("This user name already exists.")
40
- if email in emails:
41
- st.warning("This email is already being used.")
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import streamlit_authenticator as stauth
3
  import sqlite3
 
4
  import datetime
5
 
6
  # Custom imports
 
35
 
36
  if submitted and password1.strip() != password2.strip():
37
  st.warning("The passwords do not match.")
38
+ elif user_name in usernames:
39
  st.warning("This user name already exists.")
40
+ elif email in emails:
41
+ st.warning("This email is already being used.")
42
+ else:
43
+ uct_iso = datetime.datetime.utcnow().isoformat()
44
+ hashed_password = stauth.Hasher(password1).generate()
45
+ query = "INSERT INTO users(uct_iso, firstname, lastname, username, email, hashed_password) VALUES(?, ?, ?, ?, ?, ?)"
46
+ c.execute(query, (uct_iso, first_name, last_name, user_name, email, hashed_password))
47
+ c.commit()
48
+ c.close()
49
+ st.success("You have joined.")
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
  pysqlite3
2
  openpyxl
3
- streamlit-aggrid
 
1
  pysqlite3
2
  openpyxl
3
+ streamlit-authenticator