Commit 8be15634 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: WIP Fix up create new Login when Password don't comply with the policy

This prevents display error page when something is invalid.
parent aa392630
Pipeline #9629 failed with stage
in 0 seconds
......@@ -63,6 +63,25 @@
return gadget.redirect({"command": "change",
"options": {"jio_key": content.parent_relative_url,
"page": "slap_controller"}});
})
.push(undefined, function (error) {
return new RSVP.Queue()
.push(function () {
return RSVP.all([
error.target.response.text(),
gadget.getTranslationList(["Unknown Error, please open a ticket."])
]);
})
.push(function (result) {
var text = result[0],
error_message = result[0][1];
if (error.target.status === 406) {
return gadget.notifySubmitted({message: text,
status: 'error'});
}
return gadget.notifySubmitted({message: error_message,
status: 'error'});
});
});
});
});
......
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>982.32679.18615.42052</string> </value>
<value> <string>984.12854.52715.32426</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1584351093.59</float>
<float>1590705868.36</float>
<string>UTC</string>
</tuple>
</state>
......
from zExceptions import Unauthorized
import json
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
......@@ -7,13 +8,18 @@ if person.getUid() != context.getUid():
raise Unauthorized("You are not allowed to create login to a different user")
if context.Person_testLoginExistence(reference=reference):
raise Unauthorized("Login already exists")
context.REQUEST.RESPONSE.setStatus('406')
return json.dumps("Login already exists")
erp5_login = context.newContent(
try:
erp5_login = context.newContent(
portal_type = "ERP5 Login",
reference=reference,
password=password
)
erp5_login.validate()
)
erp5_login.validate()
except ValueError as e:
context.REQUEST.RESPONSE.setStatus('406')
return json.dumps(str(e))
return erp5_login.getRelativeUrl()
return json.dumps(erp5_login.getRelativeUrl())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment