32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from asciimatics.widgets import Layout, Text, Label
|
|
|
|
from ...utils import defer, http_post
|
|
from ..CeoFrame import CeoFrame
|
|
|
|
|
|
class ResetPasswordView(CeoFrame):
|
|
def __init__(self, screen, width, height, model):
|
|
super().__init__(
|
|
screen, height, width, model, 'ResetPassword',
|
|
save_data=True,
|
|
)
|
|
layout = Layout([100], fill_frame=True)
|
|
self.add_layout(layout)
|
|
layout.add_widget(Label('Enter the username of the user whose password will be reset:'))
|
|
self._username = Text(None, "uid")
|
|
layout.add_widget(self._username)
|
|
|
|
self.add_buttons(
|
|
back_btn=True,
|
|
next_scene='Confirm', on_next=self._next)
|
|
self.fix()
|
|
|
|
def _next(self):
|
|
uid = self._username.value
|
|
self._model.viewdata['ResetPassword']['uid'] = uid
|
|
self._model.confirm_lines = [
|
|
f"Are you sure you want to reset {uid}'s password?",
|
|
]
|
|
self._model.deferred_req = defer(http_post, f'/api/members/{uid}/pwreset')
|
|
self._model.result_view_name = 'ResetPasswordResult'
|