示例#1
0
    def bind(self, args):
        if current_user.is_user():
            if current_user.email:
                abort(BINDED)

            current_user.email = args['email']
            if um.config.required_bind_password:
                current_user.password = args['password']
            current_user.save()
            return current_user

        user = um.models.User.objects(email=args['email']).first()
        if not user:
            user = um.models.User(
                email=args['email'],
                password=args['password']
                if um.config.required_bind_password else '',
                channel=get_channel(),
                spm=get_spm(),
                ip=get_ip(),
            )
            user.create()
        elif um.config.required_bind_password and user.password != args[
                'password']:
            abort(PASSWORD_ERROR)
        return user
示例#2
0
文件: apis.py 项目: dodoru/chiki
 def create(self, args):
     user = um.models.User(
         email=args['email'],
         password=args['password'],
         channel=get_channel(),
         spm=get_spm(),
         ip=get_ip(),
     )
     user.create()
     return user
示例#3
0
文件: apis.py 项目: dodoru/chiki
 def bind(self, args):
     user = um.models.User.objects(email=args['email']).first()
     if not user:
         user = um.models.User(
             email=args['email'],
             password=args['password'],
             channel=get_channel(),
             spm=get_spm(),
             ip=get_ip(),
         )
         user.create()
     elif user.password != args['password']:
         abort(PASSWORD_ERROR)
     return user
示例#4
0
文件: apis.py 项目: PyFansLi/chiki
    def bind(self, args):
        if current_user.is_user():
            if current_user.phone:
                abort(BINDED)

            current_user.phone = args['phone']
            current_user.password = args['password']
            current_user.save()
            return current_user

        user = um.models.User.objects(phone=args['phone']).first()
        if not user:
            user = um.models.User(
                phone=args['phone'],
                password=args['password'],
                channel=get_channel(),
                spm=get_spm(),
                ip=get_ip(),
            )
            user.create()
        elif user.password != args['password']:
            abort(PASSWORD_ERROR)
        return user
示例#5
0
文件: models.py 项目: txfyteen/chiki
 def log(type, id, device, key='', spm=None, ip=None):
     spm = spm if spm else get_spm()
     ip = ip if ip else get_ip()
     UserLog(user=id, type=type, device=device, key=key, spm=spm,
             ip=ip).save()
示例#6
0
文件: models.py 项目: txfyteen/chiki
 def create_empty():
     return um.models.User(channel=get_channel(),
                           spm=get_spm(),
                           ip=get_ip())
示例#7
0
文件: models.py 项目: bingone/chiki
 def log(type, id, device, key='', spm=None, ip=None):
     spm = spm if spm else get_spm()
     ip = ip if ip else get_ip()
     UserLog(user=id, type=type, device=device, key=key, spm=spm, ip=ip).save()
示例#8
0
文件: models.py 项目: bingone/chiki
 def create_empty():
     return User(channel=get_channel(), spm=get_spm(), ip=get_ip())