1234567891011121314151617181920212223242526272829303132333435363738394041 |
- """
- demeter web
- name:login.py 登录相关接口
- author:rabin
- """
- from __load__ import *
- class login_path(Load):
- @Web.setting
- def get(self):
- mobile = self.input('mobile')
- password = self.input('password')
- if mobile and password:
- user = self.service('common').one('user', mobile=mobile)
- if user:
- temp = user['password'].split('_')
- if Demeter.md5(password, temp[1]) == user['password']:
- self.bind(user['id'])
-
-
- self.out('yes', {'uid':user['id']})
- return
- else:
- self.out('手机号或密码错误,登录失败')
- return
- @Web.setting
- def bind(self, uid):
- code = self.input('code')
- if not code:
- self.out('no')
- return
- url = Demeter.config['weixinApp']['login']
- url = url + '?appid=' + Demeter.config['weixinApp']['appid']
- url = url + '&secret=' + Demeter.config['weixinApp']['secret']
- url = url + '&js_code=' + code
- url = url + '&grant_type=authorization_code'
- data = Demeter.curl(url)
-
- return data
|