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)
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()
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()
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
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
def _get_by_id(device_id: int) -> Device: return session.query(Device).filter( Device.id == device_id ).first()
def get(self): devices = list(session.query(Device)) return devices
def _get_by_name(vpn_id: int) -> Vpn: return session.query(Vpn).filter( Vpn.id == vpn_id ).first()
def get(self): return list(session.query(Vpn))
def _get_by_id(device_id: int) -> Device: return session.query(Device).filter(Device.id == device_id).first()
def rules(self): qry = session.query(Device).filter(Device.vpn_id != None) return [item.rule for item in qry]
def _get_by_username(user_name: str) -> User: return session.query(User).filter( User.name == user_name ).first()
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)
def rules(self): qry = session.query(Device).filter(Device.vpn_id != None) return [ item.rule for item in qry ]