示例#1
0
def reset_password(username, password=None, config=None):
    _init_app(config)
    user = session.query(User).filter(User.name == username).first()
    if user is None:
        print('User %s not found' % username)
    if password is None:
        password = getpass('Enter new password: '******'Password reset done for user %s' % username)
示例#2
0
def reset_password(username, password=None, config=None):
    _init_app(config)
    user = session.query(User).filter(User.name == username).first()
    if user is None:
        print('User %s not found' % username)
    if password is None:
        password = getpass('Enter new password: '******'Password reset done for user %s' % username)
示例#3
0
    def decorated(*args, **kwargs):
        auth = request.authorization
        if not auth:
            return authenticate()

        user = session.query(User).filter(User.name == auth.username).first()
        if user and user.check(auth.password):
            g.user = user
            return func(*args, **kwargs)
        else:
            return authenticate()
示例#4
0
    def decorated(*args, **kwargs):
        auth = request.authorization
        if not auth:
            return authenticate()

        user = session.query(User).filter(
            User.name == auth.username
        ).first()
        if user and user.check(auth.password):
            g.user = user
            return func(*args, **kwargs)
        else:
            return authenticate()
示例#5
0
    def _update_vpn(args, device: Device) -> Device:
        orig_vpn = device.vpn
        if args.vpn:
            try:
                vpn_id = id_from_url(args.vpn, 'vpn_id')
                device.vpn = session.query(Vpn).filter(
                    Vpn.id == vpn_id).first()
            except ValueError:
                device.vpn = None
        else:
            device.vpn = None

        if orig_vpn != device.vpn:
            sync.delay()
        return device
示例#6
0
    def _update_vpn(args, device: Device) -> Device:
        orig_vpn = device.vpn
        if args.vpn:
            try:
                vpn_id = id_from_url(args.vpn, 'vpn_id')
                device.vpn = session.query(Vpn).filter(
                    Vpn.id == vpn_id
                ).first()
            except ValueError:
                device.vpn = None
        else:
            device.vpn = None

        if orig_vpn != device.vpn:
            sync.delay()
        return device
示例#7
0
 def _get_by_id(device_id: int) -> Device:
     return session.query(Device).filter(
         Device.id == device_id
     ).first()
示例#8
0
 def get(self):
     devices = list(session.query(Device))
     return devices
示例#9
0
文件: vpn.py 项目: cbrand/vpnchooser
 def _get_by_name(vpn_id: int) -> Vpn:
     return session.query(Vpn).filter(
         Vpn.id == vpn_id
     ).first()
示例#10
0
文件: vpn.py 项目: cbrand/vpnchooser
 def get(self):
     return list(session.query(Vpn))
示例#11
0
 def _get_by_id(device_id: int) -> Device:
     return session.query(Device).filter(Device.id == device_id).first()
示例#12
0
 def get(self):
     devices = list(session.query(Device))
     return devices
示例#13
0
 def rules(self):
     qry = session.query(Device).filter(Device.vpn_id != None)
     return [item.rule for item in qry]
示例#14
0
文件: user.py 项目: cbrand/vpnchooser
 def _get_by_username(user_name: str) -> User:
     return session.query(User).filter(
         User.name == user_name
     ).first()
示例#15
0
文件: user.py 项目: cbrand/vpnchooser
 def get(self):
     user = current_user()
     query = session.query(User)
     if not user.is_admin:
         query = query.filter(User.name == user.name)
     return list(query)
示例#16
0
 def rules(self):
     qry = session.query(Device).filter(Device.vpn_id != None)
     return [
         item.rule
         for item in qry
     ]