Exemplo n.º 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
Exemplo n.º 2
0
Arquivo: apis.py Projeto: 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
Exemplo n.º 3
0
Arquivo: apis.py Projeto: 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
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
 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()
Exemplo n.º 6
0
 def create_empty():
     return um.models.User(channel=get_channel(),
                           spm=get_spm(),
                           ip=get_ip())
Exemplo n.º 7
0
 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()
Exemplo n.º 8
0
 def create_empty():
     return User(channel=get_channel(), spm=get_spm(), ip=get_ip())