def account_delete(): isLogin = login_check() if isLogin: if request.method == 'GET': return render_template('admin/sthwrong.html') elif request.method == 'POST': if session['level'] > 0: # 레벨 1부터 가능 user_id = request.form['id'] if request.form.get('confirm') == 'True': users_model = Users('users', id=user_id) try: db_data = users_model.delete() if db_data['success']: return '<script>alert("성공적으로 삭제했습니다.");\n location.href="./edit";</script>' else: return render_template('admin/sthwrong.html') except Exception as e: return '<script>alert("오류가 발생했습니다.\n ' + str( e) + '");\n location.href="./edit";</script>' else: return '<script>alert("확인란에 체크하셔야 삭제할 수 있습니다.");\n history.go(-1);</script>' else: return '<script>alert("권한이 없습니다.");\n history.go(-1);</script>' else: return redirect(url_for('admin.login'))
def delete(self, user_id): level = get_jwt_claims()['level'] if level < 1: return { 'success': False, 'msg': 'Unavailable request to level 0 user.' }, 403 users_model = Users('users', id=user_id) return users_model.delete()