user.py 747 B

123456789101112131415161718192021222324252627282930
  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 post(self):
  12. mobile = self.input('username')
  13. password = self.input('password')
  14. if mobile and password:
  15. user = self.service('common').one('farm_user', mobile=mobile)
  16. if user:
  17. temp = user['password'].split('_')
  18. if Demeter.md5(password, temp[1]) == user['password']:
  19. self.set_secure_cookie('user', str(user['id']))
  20. self.out('yes', {'id':user['id']})
  21. return
  22. self.out('手机号或安全码错误,登录失败')
  23. class loginout_path(Load):
  24. @Web.setting
  25. def get(self):
  26. self.set_secure_cookie('user', '')
  27. self.redirect('/user/login')