Commit f6fe1929463102a0a2cfa3f721bc6f3d98fbef04

Authored by soochanlee ago
1 parent c1e6ac357b
Exists in master

adding comments on source

Showing 1 changed file with 15 additions and 9 deletions Side-by-side Diff

project/project/controller/printer.py View file @ f6fe192
... ... @@ -47,25 +47,30 @@
47 47 logout()
48 48 return redirect(url_for('login'))
49 49  
50   -""" main page controller """
  50 +
51 51 @app.route('/',methods=['GET','POST'])
52 52 @app.route('/index', methods=['GET','POST'])
53 53 def index():
54   -
  54 + """ main page controller """
  55 +
  56 + ### Check login
55 57 if is_login() == False:
56 58 return redirect(url_for('login'))
57 59  
58 60 data = []
59 61 user_id=""
60 62 del_flag = 0
  63 +
  64 + ### On click delete user button
61 65 if request.form.has_key('del_user'):
62 66 del_user = request.form['del_user']
63 67 if len(del_user) > 0:
64   - print del_user
  68 + ## Run delete user on thread
65 69 thread = threading.Thread(target=utils.del_userById, args=[del_user])
66 70 thread.start()
67 71 del_flag = 2
68   - #del_flag = utils.del_userById(del_user)
  72 +
  73 + ### On search user
69 74 if request.form.has_key('user_id'):
70 75 user_id = request.form['user_id']
71 76 if len(user_id) > 0:
72 77  
... ... @@ -75,9 +80,10 @@
75 80 return render_template('user.html',data=data, search=user_id, del_flag=del_flag)
76 81  
77 82  
78   -""" login page controller """
  83 +
79 84 @app.route('/auth', methods=['GET','POST'])
80 85 def login():
  86 + """ login page controller """
81 87 error = 0
82 88 form = LoginForm()
83 89  
84 90  
... ... @@ -85,8 +91,8 @@
85 91 session['fail_cnt'] = 0
86 92 session['fail_date'] = 0
87 93  
  94 + ### Check if this session has login fail count
88 95 if session['fail_cnt'] > 4:
89   -
90 96 if get_dateSub() > 10 * 60:
91 97 session['fail_cnt'] = 0
92 98 session['fail_date'] = 0
93 99  
94 100  
95 101  
96 102  
... ... @@ -94,17 +100,17 @@
94 100 error = -2
95 101 return render_template('login.html', error=error, form=form)
96 102  
97   -
  103 + #### On click login
98 104 if form.validate_on_submit() and session['fail_cnt'] < 5:
  105 + ## If login success
99 106 if form.ID.data == admin_user['id'] and form.passwd.data == admin_user['passwd']:
100   - #admin_user['login'] = True
101 107 #admin_user['auth'] = hashlib.sha256(admin_user['id'] + admin_user['passwd'] + str(get_date(0))).hexdigest()
102 108 session['is_login'] = True
103 109 session['fail_cnt'] = 0
104   - #admin_user['fail_cnt'] = 0
105 110  
106 111 session.permanent = True
107 112 return render_template('user.html',data=[], search='', del_flag=0)
  113 + ## If login fail
108 114 else:
109 115 error = -1
110 116 session['fail_cnt'] += 1