mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-22 10:24:26 +01:00
doorlockd: frontend: support local authentication
Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
parent
45724f37c8
commit
f5603272d2
10
doorlockd
10
doorlockd
@ -408,6 +408,7 @@ class Logic:
|
||||
class AuthenticationForm(FlaskForm):
|
||||
username = StringField('Username', [Length(min=3, max=25)])
|
||||
password = PasswordField('Password', [DataRequired()])
|
||||
method = StringField('Method', [DataRequired()])
|
||||
open = SubmitField('Open')
|
||||
present = SubmitField('Present')
|
||||
close = SubmitField('Close')
|
||||
@ -425,6 +426,11 @@ class AuthenticationForm(FlaskForm):
|
||||
elif self.present.data:
|
||||
self.desired_state = DoorState.Present
|
||||
|
||||
if self.method.data == 'Local':
|
||||
self.method = AuthMethod.LOCAL_USER_DB
|
||||
else: # default: use LDAP
|
||||
self.method = AuthMethod.LDAP_USER_PW
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@ -500,9 +506,11 @@ def home():
|
||||
if request.method == 'POST' and authentication_form.validate():
|
||||
user = authentication_form.username.data
|
||||
password = authentication_form.password.data
|
||||
credentials = AuthMethod.LDAP_USER_PW, user, password
|
||||
method = authentication_form.method
|
||||
credentials = method, user, password
|
||||
|
||||
log.info('Incoming request from %s' % user.encode('utf-8'))
|
||||
log.info(' authentication method: %s' % method)
|
||||
desired_state = authentication_form.desired_state
|
||||
log.info(' desired state: %s' % desired_state)
|
||||
log.info(' current state: %s' % logic.state)
|
||||
|
@ -23,6 +23,13 @@
|
||||
<label class="control-label" for="password">Password</label>
|
||||
<input class="form-control" id="password" name="password" required type="password" value="">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="method">Authentication method</label>
|
||||
<select name="method" id="method" class="form-control">
|
||||
<option selected>LDAP</option>
|
||||
<option>Local</option>
|
||||
</select>
|
||||
</div>
|
||||
<input class="btn btn-success btn-lg btn-block" id="open" name="open" type="submit" value="Open">
|
||||
<input class="btn btn-warning btn-lg btn-block" id="present" name="present" type="submit" value="Present">
|
||||
<input class="btn btn-danger btn-lg btn-block" id="close" name="close" type="submit" value="Close">
|
||||
|
Loading…
Reference in New Issue
Block a user