2DU 9 лет назад
Родитель
Сommit
858fd55849
2 измененных файлов с 55 добавлено и 10 удалено
  1. 34 1
      app.py
  2. 21 9
      templates/index.html

+ 34 - 1
app.py

@@ -2423,6 +2423,39 @@ def login():
             else:
                 return render_template('index.html', title = '로그인', enter = '로그인', logo = data['name'], tn = 15)
                 
+@app.route('/change', methods=['POST', 'GET'])
+def change():
+    if(request.method == 'POST'):
+        ip = getip(request)
+        ban = getban(ip)
+        if(ban == 1):
+            return '<meta http-equiv="refresh" content="0;url=/ban" />'
+        else:
+            curs.execute("select * from user where id = '" + pymysql.escape_string(request.form["id"]) + "'")
+            rows = curs.fetchall()
+            if(rows):
+                if(session.get('Now') == True):
+                    return '<meta http-equiv="refresh" content="0;url=/logout" />'
+                elif(bcrypt.checkpw(bytes(request.form["pw"], 'utf-8'), bytes(rows[0]['pw'], 'utf-8'))):
+                    hashed = bcrypt.hashpw(bytes(request.form["pw2"], 'utf-8'), bcrypt.gensalt())
+                    curs.execute("update user set pw = '" + pymysql.escape_string(hashed.decode()) + "' where id = '" + pymysql.escape_string(request.form["id"]) + "'")
+                    conn.commit()
+                    return '<meta http-equiv="refresh" content="0;url=/login" />'
+                else:
+                    return render_template('index.html', title = '변경 오류', logo = data['name'], data = '비밀번호가 다릅니다.')
+            else:
+                return render_template('index.html', title = '변경 오류', logo = data['name'], data = '없는 계정 입니다.')
+    else:
+        ip = getip(request)
+        ban = getban(ip)
+        if(ban == 1):
+            return '<meta http-equiv="refresh" content="0;url=/ban" />'
+        else:
+            if(session.get('Now') == True):
+                return '<meta http-equiv="refresh" content="0;url=/logout" />'
+            else:
+                return render_template('index.html', title = '비밀번호 변경', enter = '비밀번호 변경', logo = data['name'], tn = 15)
+                
 @app.route('/check/<path:name>')
 def check(name = None, sub = None, number = None):
     curs.execute("select * from user where id = '" + pymysql.escape_string(name) + "'")
@@ -2739,7 +2772,7 @@ def user():
             acl = '일반'
     else:
         acl = '차단'
-    return render_template('index.html', title = '유저 메뉴', logo = data['name'], data = ip + '<br><br><span>권한 상태 : ' + acl + '<br><br><li><a href="/login">로그인</a></li><li><a href="/logout">로그아웃</a></li><li><a href="/register">회원가입</a></li>')
+    return render_template('index.html', title = '유저 메뉴', logo = data['name'], data = ip + '<br><br><span>권한 상태 : ' + acl + '<br><br><li><a href="/login">로그인</a></li><li><a href="/logout">로그아웃</a></li><li><a href="/register">회원가입</a></li><li><a href="/change">비밀번호 변경</a></li>')
 
 @app.route('/random')
 def random():

+ 21 - 9
templates/index.html

@@ -352,13 +352,15 @@
                     <li>유저 가입 목록 (완료)</li>
                     <li>최근 차단을 유저 차단 기록으로 (완료)</li>
                     <h2>1.6</h2>
-                    <li>토론에 AJAX 적용 (1.6.3)</li>
-                    <li>리캡차 추가 (1.6.4)</li>
-                    <li>섬네일 기능 (1.6.5)</li>
-                    <li>역링크 기능 완성 (완료?)</li>
-                    <li>분류 완성 (완료?)</li>
-                    <li>팝업 각주 (미정)</li>
-                    <li>업로드 보강 (미정)</li>
+                    <li>역링크 기능 완성 (완료)</li>
+                    <li>분류 완성 (완료)</li>
+                    <li>팝업 각주</li>
+                    <li>비밀번호 변경 (완료)</li>
+                    <h2>1.7</h2>
+                    <li>토론에 AJAX 적용</li>
+                    <li>리캡차 추가</li>
+                    <li>섬네일 기능</li>
+                    <li>업로드 보강</li>
                     <h2>계속</h2>
                     <li>버그 수정</li>
                     <li>파서 제작 (Last 1.6.2)</li>
@@ -370,7 +372,7 @@
                     <li>일부 파일 <a class="out_link" href="https://twitter.com/Basix1120">Basix</a></li>
                     <br>
                     <h2>기타</h2>
-                    <li>버전 1.6.2 - 정식</li>
+                    <li>버전 1.6.4 - 정식</li>
                     <br>
                     <h2>개발 이념</h2>
                     <li>나(<a class="out_link" href="https://github.com/2DU">2DU</a>) 쓰기 편한 엔진을 만들자</li>
@@ -379,6 +381,8 @@
                 <h1 class="title">{{title}}</h1>
                 {% if title == '회원가입' %}
                 <form id="usrform" method="POST" action="/register">
+                {% elif title == '비밀번호 변경' %}
+                <form id="usrform" method="POST" action="/change">
                 {% else %}
                 <form id="usrform" method="POST" action="/login">
                 {% endif %}
@@ -388,12 +392,20 @@
                     <input name="id" type="text">
                     <br>
                     <br>
-                    <span>비밀번호</span>
+                    <span>{% if title == '비밀번호 변경' %}현재{% endif %}비밀번호</span>
                     <br>
                     <br>
                     <input name="pw" type="password">
                     <br>
                     <br>
+                    {% if title == '비밀번호 변경' %}
+                    <span>바꿀 비밀번호</span>
+                    <br>
+                    <br>
+                    <input name="pw2" type="password">
+                    <br>
+                    <br>
+                    {% endif %}
                     <button class="btn btn-primary" type="submit">{{enter}}</button>
                 </form>
                 {% elif tn == 16 %}