def reset(self, request): """Get reset form and handle rest password """ key = request.urlargs['key'] if request.method == 'GET': form = get_form_layout(request, 'reset-password') if not form: raise Http404 request.api.passwords.head(key, jwt=True) html = form(request).as_form(action=request.full_path(), enctype='multipart/form-data', method='post') return self.html_response(request, html) else: form = _auth_form(request, 'reset-password') if form.is_valid(): try: result = request.api.passwords.post( key, json=form.cleaned_data, jwt=True ).json() except Exception as exc: result = form_http_exception(form, exc) else: result = form.tojson() return self.json_response(request, result)
def get_form(self, request, form=None, id=None, model=None, initial=None, **params): if id: params['action'] = 'update' form = form or self.updateform or self.form else: params['action'] = 'create' form = form or self.form form = get_form_layout(request, form) if not form: raise Http404 target = self.get_target(request, path=id, model=model, **params) if id: request.api.head(target) form = form(request, initial=initial, model=model) if 'json' in request.url_data: return form.as_dict(action=target) else: return form.as_form(action=target)
def reset(self, request): """Get reset form and handle rest password """ key = request.urlargs['key'] if request.method == 'GET': form = get_form_layout(request, 'reset-password') if not form: raise Http404 request.api.passwords.head(key, jwt=True) html = form(request).as_form(action=request.full_path(), enctype='multipart/form-data', method='post') return self.html_response(request, html) else: form = _auth_form(request, 'reset-password') if form.is_valid(): try: result = request.api.passwords.post(key, json=form.cleaned_data, jwt=True).json() except Exception as exc: result = form_http_exception(form, exc) else: result = form.tojson() return self.json_response(request, result)