Przeglądaj źródła

Fix a bug that email is lost during registration

Fixed a bug that email address is not saved when approval requirement is
enabled
LiteHell 6 lat temu
rodzic
commit
ae49319ebc
4 zmienionych plików z 8 dodań i 5 usunięć
  1. 1 1
      app.py
  2. 3 1
      route/applications.py
  3. 3 2
      route/login_check_key.py
  4. 1 1
      route/login_register.py

+ 1 - 1
app.py

@@ -176,7 +176,7 @@ if setup_tool != 0:
     create_data['rd'] = ['title', 'sub', 'date', 'band', 'stop', 'agree']
     create_data['user'] = ['id', 'pw', 'acl', 'date', 'encode']
     create_data['user_set'] = ['name', 'id', 'data']
-    create_data['user_application'] = ['id', 'pw', 'date', 'encode', 'question', 'answer', 'ip', 'ua', 'token']
+    create_data['user_application'] = ['id', 'pw', 'date', 'encode', 'question', 'answer', 'ip', 'ua', 'token', 'email']
     create_data['ban'] = ['block', 'end', 'why', 'band', 'login']
     create_data['topic'] = ['id', 'title', 'sub', 'data', 'date', 'ip', 'block', 'top', 'code']
     create_data['rb'] = ['block', 'end', 'today', 'blocker', 'why', 'band']

+ 3 - 1
route/applications.py

@@ -55,7 +55,7 @@ def applications_2(conn):
             div += load_lang('no_applications_now')
     else:
         if flask.request.form.get('approve', '') != '':
-            curs.execute(db_change('select id, pw, date, encode, question, answer, ip, ua from user_application where token = ?'), [flask.request.form.get('approve', '')])
+            curs.execute(db_change('select id, pw, date, encode, question, answer, ip, ua, email from user_application where token = ?'), [flask.request.form.get('approve', '')])
             application = curs.fetchall()
             if not application:
                 return re_error('/error/26')
@@ -70,6 +70,8 @@ def applications_2(conn):
             curs.execute(db_change("insert into user_set (name, id, data) values ('approval_question', ?, ?)"), [application[0], application[4]])
             curs.execute(db_change("insert into user_set (name, id, data) values ('approval_question_answer', ?, ?)"), [application[0], application[5]])
             curs.execute(db_change("insert into ua_d (name, ip, ua, today, sub) values (?, ?, ?, ?, '')"), [application[0], application[6], application[7], application[2]])
+            if application[8] and application[8] != '':
+                curs.execute(db_change("insert into user_set (name, id, data) values ('email', ?, ?)"), [application[0], application[8]])
             curs.execute(db_change('delete from user_application where token = ?'), [flask.request.form.get('approve', '')])
  
 

+ 3 - 2
route/login_check_key.py

@@ -54,7 +54,7 @@ def login_check_key_2(conn, tool):
                         requires_approval = curs.fetchall()
                         if requires_approval and requires_approval[0][0] == 'on':
                             application_token = ''.join(random.choice("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") for i in range(60))
-                            curs.execute(db_change("insert into user_application (id, pw, date, encode, question, answer, token, ip, ua) values (?, ?, ?, ?, ?, ?, ?, ?, ?)"), [
+                            curs.execute(db_change("insert into user_application (id, pw, date, encode, question, answer, token, ip, ua, email) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"), [
                                 flask.session['c_id'],
                                 flask.session['c_pw'],
                                 get_time(),
@@ -63,7 +63,8 @@ def login_check_key_2(conn, tool):
                                 flask.session['c_ans'],
                                 application_token,
                                 ip,
-                                flask.request.headers.get('User-Agent')
+                                flask.request.headers.get('User-Agent'),
+                                flask.session['c_email']
                             ])
                             conn.commit()
 

+ 1 - 1
route/login_register.py

@@ -83,7 +83,7 @@ def login_register_2(conn):
             else:
                 if requires_approval:
                     application_token = ''.join(random.choice("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") for i in range(60))
-                    curs.execute(db_change("insert into user_application (id, pw, date, encode, question, answer, token, ip, ua) values (?, ?, ?, ?, ?, ?, ?, ?, ?)"), [flask.request.form.get('id', None), hashed, get_time(), db_data[0][0], approval_question, flask.request.form.get('approval_question_answer', None), application_token, ip_check(), flask.request.headers.get('User-Agent')])
+                    curs.execute(db_change("insert into user_application (id, pw, date, encode, question, answer, token, ip, ua, email) values (?, ?, ?, ?, ?, ?, ?, ?, ?, '')"), [flask.request.form.get('id', None), hashed, get_time(), db_data[0][0], approval_question, flask.request.form.get('approval_question_answer', None), application_token, ip_check(), flask.request.headers.get('User-Agent')])
                     conn.commit()
                     return redirect('/application_submitted')
                 else: