예제 #1
0
	def post(self):
		form=AdminLoginForm(self)
		if form.validate():
			username=form.username.data
			password=unicode(hashlib.md5(form.password.data).hexdigest(),'utf-8');
			user=self.db.get("SELECT * FROM userinfo Where username=%s",username)
			if user and user.password == password:
				self.set_secure_cookie("user", str(user.user_id))
				return self.redirect('/admin/home')
			else:
				form.password.errors.append("密码输入错误!")
		return self.render("admin/login.html",loginform=form)
예제 #2
0
파일: admin.py 프로젝트: afei263/leeblog
 def post(self):
     form = AdminLoginForm(self)
     if form.validate():
         username = form.username.data
         password = unicode(hashlib.md5(form.password.data).hexdigest(),'utf-8');
         user = self.db.query(User).filter_by(loginname=username).first()
         if user and user.password == password:
             self.set_secure_cookie("blogadmin_user", user.loginname)
             return self.redirect('/admin/home')
         else:
             form.password.errors.append('Username or Password is wrong')
     return self.render("admin/login.html",loginform=form)
예제 #3
0
 def post(self):
     form = AdminLoginForm(self)
     if form.validate():
         username = form.username.data
         password = unicode(
             hashlib.md5(form.password.data).hexdigest(), 'utf-8')
         user = self.db.query(User).filter_by(loginname=username).first()
         if user and user.password == password:
             self.set_secure_cookie("blogadmin_user", user.loginname)
             return self.redirect('/admin/home')
         else:
             form.password.errors.append('Username or Password is wrong')
     return self.render("admin/login.html", loginform=form)
예제 #4
0
 def get(self):
     if not self.current_user:
         form = AdminLoginForm(self)
         self.render("admin/login.html", loginform=form)
     else:
         return self.redirect('/admin/home')