Compare commits
No commits in common. "4307d54505ea56b5776bb2ce47643aad2848123f" and "2ccec6fe32df68198ebddc5d5597360e5a12991f" have entirely different histories.
4307d54505
...
2ccec6fe32
|
@ -92,15 +92,15 @@ class DoorHandle:
|
||||||
if self.nfc_sock is not None:
|
if self.nfc_sock is not None:
|
||||||
self.nfc_sock.send(b'rld\n')
|
self.nfc_sock.send(b'rld\n')
|
||||||
|
|
||||||
def open_door(self, user=b''):
|
def open_door(self):
|
||||||
if self.nfc_sock is not None:
|
if self.nfc_sock is not None:
|
||||||
self.nfc_sock.send(b'open ' + user + b'\n')
|
self.nfc_sock.send(b'open\n')
|
||||||
else:
|
else:
|
||||||
raise Exception("No connection to NFC socket. Cannot close door!")
|
raise Exception("No connection to NFC socket. Cannot close door!")
|
||||||
|
|
||||||
def close_door(self, user=b''):
|
def close_door(self):
|
||||||
if self.nfc_sock is not None:
|
if self.nfc_sock is not None:
|
||||||
self.nfc_sock.send(b'close ' + user + b'\n')
|
self.nfc_sock.send(b'close\n')
|
||||||
else:
|
else:
|
||||||
raise Exception("No connection to NFC socket. Cannot close door!")
|
raise Exception("No connection to NFC socket. Cannot close door!")
|
||||||
|
|
||||||
|
|
|
@ -207,19 +207,18 @@ def create_application(config):
|
||||||
new_user_data['password'] = hash_password(password)
|
new_user_data['password'] = hash_password(password)
|
||||||
new_user_data['roles'] = []
|
new_user_data['roles'] = []
|
||||||
lock_permission = con.search('ou=Users,dc=imaginaerraum,dc=de',
|
lock_permission = con.search('ou=Users,dc=imaginaerraum,dc=de',
|
||||||
f'(&(uid={username})(memberof=cn=Keyholders,ou=Groups,dc=imaginaerraum,dc=de))',
|
f'(&(uid={username})(memberof=cn=Members,ou=Groups,dc=imaginaerraum,dc=de))',
|
||||||
attributes=ldap3.ALL_ATTRIBUTES)
|
attributes=ldap3.ALL_ATTRIBUTES)
|
||||||
authorized = True
|
|
||||||
if lock_permission:
|
if lock_permission:
|
||||||
new_user_data['email'] = con.entries[0].mail.value
|
new_user_data['email'] = con.entries[0].mail.value
|
||||||
else:
|
else:
|
||||||
authorized = False
|
new_user_data['email'] = None
|
||||||
token_granting_permission = con.search('ou=Users,dc=imaginaerraum,dc=de',
|
token_granting_permission = con.search('ou=Users,dc=imaginaerraum,dc=de',
|
||||||
f'(&(uid={username})(memberof=cn=Vorstand,ou=Groups,dc=imaginaerraum,dc=de))')
|
f'(&(uid={username})(memberof=cn=Vorstand,ou=Groups,dc=imaginaerraum,dc=de))')
|
||||||
if token_granting_permission:
|
if token_granting_permission:
|
||||||
new_user_data['roles'].append('admin')
|
new_user_data['roles'].append('admin')
|
||||||
|
|
||||||
return authorized, new_user_data
|
return True, new_user_data
|
||||||
|
|
||||||
class ExtendedLoginForm(LoginForm):
|
class ExtendedLoginForm(LoginForm):
|
||||||
email = StringField('Benutzername oder E-Mail', [Required()])
|
email = StringField('Benutzername oder E-Mail', [Required()])
|
||||||
|
@ -678,9 +677,8 @@ def create_application(config):
|
||||||
@app.route('/open')
|
@app.route('/open')
|
||||||
@auth_required()
|
@auth_required()
|
||||||
def open_door():
|
def open_door():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
door.open_door(user=current_user.username)
|
door.open_door()
|
||||||
logger.info(f"Door opened by admin user {current_user.username}")
|
logger.info(f"Door opened by admin user {current_user.username}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
flash(f'Could not open door. Exception: {e}')
|
flash(f'Could not open door. Exception: {e}')
|
||||||
|
@ -691,7 +689,7 @@ def create_application(config):
|
||||||
@auth_required()
|
@auth_required()
|
||||||
def close_door():
|
def close_door():
|
||||||
try:
|
try:
|
||||||
door.close_door(user=current_user.username)
|
door.close_door()
|
||||||
logger.info(f"Door closed by admin user {current_user.username}")
|
logger.info(f"Door closed by admin user {current_user.username}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
flash(f'Could not close door. Exception: {e}')
|
flash(f'Could not close door. Exception: {e}')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user