user.py 840 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter web page
  5. name:user.py
  6. author:rabin
  7. """
  8. from __load__ import *
  9. class login_path(Load):
  10. @Web.setting
  11. def get(self):
  12. self.view("login.html")
  13. @Web.setting
  14. def post(self):
  15. mobile = self.input('username')
  16. password = self.input('password')
  17. if mobile and password:
  18. admin = self.service('common').one('manage_admin', mobile=mobile)
  19. if admin:
  20. temp = admin['password'].split('_')
  21. if Demeter.md5(password, temp[1]) == admin['password']:
  22. self.set_secure_cookie('admin', str(admin['id']))
  23. #self.redirect('/')
  24. self.out('yes', {'id':admin['id']})
  25. return
  26. self.out('手机号或密码错误,登录失败')
  27. class loginout_path(Load):
  28. @Web.setting
  29. def get(self):
  30. self.set_secure_cookie('admin', '')
  31. self.redirect('/user/login')