def onsubmitpress(self): if len(self.username.get()) == 0: messagebox.showerror('Incorrect username', "Username can not be empty") return if len(self.password.get()) == 0: messagebox.showerror("Incorrect password", "Password can not be empty") return userdetails = auth_user(self.username.get(), self.password.get()) print(userdetails) if userdetails is None: messagebox.showerror("login failed", "Username and Password doesn't match") else: print(userdetails[1]) if userdetails[1]['privilege'] == 'admin': self.destroy() from admin_dashboard import AdminDashboard adminscreen = AdminDashboard(userdetails=userdetails[1]) adminscreen.mainloop() # admin_dashboard starts elif userdetails[1]['privilege'] == 'employee': self.destroy() from employee_dashboard import EmployeeDashboard employeescreen = EmployeeDashboard(userdetails=userdetails[1]) employeescreen.mainloop()
def login(): if request.method == 'POST': username = request.form.get('username') password = request.form.get('password') if db.auth_user(username, password): session['username'] = username return redirect('/users/') return render_template('login.html', errormsg='Account or passowrd error!') return render_template('login.html')
def login(): if request.method == 'POST': username = request.form.get('username') password = request.form.get('password') if db.auth_user(username, password): return redirect('/users/') return render_template('login.html', errormsg='Account or passowrd error!') return render_template('login.html')
def login(): if request.method == "POST": name = request.form.get('name') #接收用户提交的数据 password = request.form.get('password') print name and password if db.auth_user(name, password): return redirect('/userlist') return redirect('/login/') else: return render_template('login.html')
def login(): if request.method == 'POST': username = request.form.get('username') password = request.form.get('password') if db.auth_user(username, password): session['username'] = username session['role'] = db.get_user_role(username) return redirect('/user_center/') return render_template('login.html', errormsg='Account or passowrd error!') return render_template('login.html')
def login(): if request.method == 'POST': username = request.form.get('username') password = db.calc_md5(request.form.get('password')) if db.auth_user(username, password): session['username'] = username session['role'] = db.get_user_role(username) util.WriteLog('infoLogger').info('%s is login' % (session['username'])) return redirect('/user_center/') return render_template('login.html', errormsg='Account or passowrd error!') return render_template('login.html')
def login_required(): username = request.form.get('username') password = request.form.get('password') if db.auth_user(username, password): return redirect('/users/') return redirect('/login/')
sockfd, addr = server_socket.accept() CONNECTION_LIST.append(sockfd) db.logging.info(u'Client (%s, %s) connected' % addr) #Some incoming message from a client else: # Data recieved from client, process it try: #In Windows, sometimes when a TCP program closes abruptly, # a "Connection reset by peer" exception will be thrown data = sock.recv(RECV_BUFFER) if data: user_data = json.loads(data) db.logging.info(u'called server operation: ' + str(user_data["operation"])) if "login" == user_data["operation"]: if not db.auth_user(user_data['user'], user_data['password'], user_data['type']): send_text = 'fail' db.logging.info(u'Client (%s, %s) login wrong' % addr) sock.close() CONNECTION_LIST.remove(sock) else: base_data = db.auth_user(user_data['user'], user_data['password'], user_data['type']) if users: if not base_data['user_name'] in users: users[base_data['user_name']] = addr else: users[base_data['user_name']] = addr for room in base_data['user_rooms']:
def login(email, password): if db.auth_user(email, password): session['u_id'] = db.get_user_id(email) return True return False