Exemple #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
Exemple #2
0
 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
Exemple #3
0
 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
Exemple #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
Exemple #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()
Exemple #6
0
 def create_empty():
     return um.models.User(channel=get_channel(),
                           spm=get_spm(),
                           ip=get_ip())
Exemple #7
0
 def login(self):
     """ 用户登录 """
     self.logined = datetime.now()
     self.ip = get_ip()
     self.spm = request.args.get('spm', self.spm)
     self.save()
Exemple #8
0
 def login(self):
     """ 用户登录 """
     self.logined = datetime.now()
     self.ip = get_ip()
     self.spm = request.args.get('spm', self.spm)
     self.save()
Exemple #9
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()
Exemple #10
0
 def create_empty():
     return User(channel=get_channel(), spm=get_spm(), ip=get_ip())