user.py 798 B

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