12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- # -*- coding: utf-8 -*-
- """
- demeter web page
- name:user.py
- author:rabin
- """
- from .__load__ import *
- class login_path(Load):
- def get(self):
- #url = Demeter.config['web']['url']
- #self.redirect(url)
- mobile = self.input('username')
- password = self.input('password')
- if mobile and password:
- user = self.service('common').one('farm_user', mobile=mobile)
- if user:
- temp = user['password'].split('_')
- if password + '_' + temp[1] == user['password']:
- self.set_secure_cookie('user', str(user['id']))
- url = self.input('url', '/device')
- self.redirect(url)
- self.data['url'] = self.input('url', '/device')
- self.view("login.html")
- def post(self):
- mobile = self.input('username')
- password = self.input('password')
- if mobile and password:
- user = self.service('common').one('farm_user', mobile=mobile)
- if user:
- temp = user['password'].split('_')
- if Demeter.md5(password, temp[1]) == user['password']:
- self.set_secure_cookie('user', str(user['id']))
- self.out('yes', {'id':user['id']})
- return
- self.out('手机号或安全码错误,登录失败')
-
- class loginout_path(Load):
- def get(self):
- self.set_secure_cookie('user', '')
- self.redirect('/user/login')
|