mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-12 09:17:56 +03:00
Added sumarize to authenticators
This commit is contained in:
parent
bf3d36c901
commit
0b66300805
@ -154,26 +154,34 @@ class Authenticators(ModelHandler):
|
||||
raise exceptions.rest.NotFound('type not found') from e
|
||||
|
||||
def item_as_dict(self, item: 'Model') -> dict[str, typing.Any]:
|
||||
summary = 'summarize' in self._params
|
||||
|
||||
item = ensure.is_instance(item, Authenticator)
|
||||
type_ = item.get_type()
|
||||
return {
|
||||
v = {
|
||||
'numeric_id': item.id,
|
||||
'id': item.uuid,
|
||||
'name': item.name,
|
||||
'tags': [tag.tag for tag in item.tags.all()],
|
||||
'comments': item.comments,
|
||||
'priority': item.priority,
|
||||
'net_filtering': item.net_filtering,
|
||||
'networks': [{'id': n.uuid} for n in item.networks.all()],
|
||||
'state': item.state,
|
||||
'mfa_id': item.mfa.uuid if item.mfa else '',
|
||||
'small_name': item.small_name,
|
||||
'users_count': item.users.count(),
|
||||
'type': type_.get_type(),
|
||||
'type_name': type_.name(),
|
||||
'type_info': self.type_info(type_),
|
||||
'permission': permissions.effective_permissions(self._user, item),
|
||||
}
|
||||
if not summary:
|
||||
type_ = item.get_type()
|
||||
v.update(
|
||||
{
|
||||
'tags': [tag.tag for tag in item.tags.all()],
|
||||
'comments': item.comments,
|
||||
'net_filtering': item.net_filtering,
|
||||
'networks': [{'id': n.uuid} for n in item.networks.all()],
|
||||
'state': item.state,
|
||||
'mfa_id': item.mfa.uuid if item.mfa else '',
|
||||
'small_name': item.small_name,
|
||||
'users_count': item.users.count(),
|
||||
'type': type_.get_type(),
|
||||
'type_name': type_.name(),
|
||||
'type_info': self.type_info(type_),
|
||||
'permission': permissions.effective_permissions(self._user, item),
|
||||
}
|
||||
)
|
||||
return v
|
||||
|
||||
def post_save(self, item: 'Model') -> None:
|
||||
item = ensure.is_instance(item, Authenticator)
|
||||
|
@ -320,14 +320,14 @@ def mfa(
|
||||
remember_device = _('{} hours').format(mfa_provider.remember_device)
|
||||
|
||||
# Html from MFA provider
|
||||
mfaHtml = mfa_instance.html(request, mfa_user_id, request.user.name)
|
||||
mfa_html = mfa_instance.html(request, mfa_user_id, request.user.name)
|
||||
|
||||
# Redirect to index, but with MFA data
|
||||
request.session['mfa'] = {
|
||||
'label': label or _('MFA Code'),
|
||||
'validity': validity if validity >= 0 else 0,
|
||||
'remember_device': remember_device,
|
||||
'html': mfaHtml,
|
||||
'html': mfa_html,
|
||||
}
|
||||
return index(request) # Render index with MFA data
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user