Commit b7117350 authored by Marcel Rieger's avatar Marcel Rieger
Browse files

Fix ajax responses in login.js for login, password reset and registration....

Fix ajax responses in login.js for login, password reset and registration. Update paw tests as well.
parent 77e2782f
......@@ -5,12 +5,12 @@
<databaseInfo>
<version>134481920</version>
<UUID>78B86AAE-4700-4884-A7DD-40EB3F37CEDE</UUID>
<nextObjectID>119</nextObjectID>
<nextObjectID>131</nextObjectID>
<metadata>
<plist version="1.0">
<dict>
<key>NSPersistenceFrameworkVersion</key>
<integer>526</integer>
<integer>640</integer>
<key>NSStoreModelVersionHashes</key>
<dict>
<key>LMCookieJar</key>
......@@ -61,8 +61,9 @@
</metadata>
</databaseInfo>
<object type="LMREQUEST" id="z103">
<attribute name="body" type="string">[{"data":{"keyValues":[[["username"],[{"data":{"environmentVariable":"10E33EB2-6E5C-42B0-BC8B-94758704580C"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"}],true],[["password"],[{"data":{"environmentVariable":"B9C862C6-9E0B-4049-AC8F-76009A1CBF28"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"}],true]]},"identifier":"com.luckymarmot.BodyFormKeyValueDynamicValue"}]</attribute>
<attribute name="uuid" type="string">453D0328-6FE8-4277-9042-0085C387FD24</attribute>
<attribute name="url" type="string">[{"name":"com.luckymarmot.Paw.DynamicValue","data":"62706C6973743030D40102030405061D1E582476657273696F6E58246F626A65637473592461726368697665725424746F7012000186A0A507080D111855246E756C6CD2090A0B0C5F1013656E7669726F6E6D656E745661726961626C655624636C61737380028004D20A0E0F10594E532E737472696E6780035F102430434537393743352D413134382D343536332D383441442D303130353830393843433633D2121314155A24636C6173736E616D655824636C61737365735F100F4E534D757461626C65537472696E67A3141617584E53537472696E67584E534F626A656374D21213191A5F10214C4D456E7669726F6E6D656E745661726961626C6544796E616D696356616C7565A31B1C175F10214C4D456E7669726F6E6D656E745661726961626C6544796E616D696356616C75655E4C4D44796E616D696356616C75655F100F4E534B657965644172636869766572D11F2054726F6F74800100080011001A0023002D00320037003D00430048005E006500670069006E0078007A00A100A600B100BA00CC00D000D900E200E7010B010F0133014201540157015C000000000000020100000000000000210000000000000000000000000000015E"},"\\/ajax\\/login?username=Marcel\u2600password=123123123"]</attribute>
<attribute name="url" type="string">[{"data":{"environmentVariable":"0CE797C5-A148-4563-84AD-01058098CC63"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"},"\\/ajax\\/login"]</attribute>
<attribute name="timeoutinterval" type="float">30</attribute>
<attribute name="storecookies" type="bool">1</attribute>
<attribute name="sendcookies" type="bool">1</attribute>
......@@ -70,7 +71,7 @@
<attribute name="redirectauthorization" type="bool">0</attribute>
<attribute name="method" type="string">POST</attribute>
<attribute name="followredirects" type="bool">0</attribute>
<attribute name="order" type="int64">0</attribute>
<attribute name="order" type="int64">1</attribute>
<attribute name="name" type="string">login</attribute>
<relationship name="parent" type="0/1" destination="LMREQUESTTREEITEM"></relationship>
<relationship name="children" type="0/0" destination="LMREQUESTTREEITEM"></relationship>
......@@ -87,7 +88,7 @@
<attribute name="method" type="string">POST</attribute>
<attribute name="followredirects" type="bool">0</attribute>
<attribute name="body" type="string">[{"data":{"keyValues":[[["wid"],["1"],true]]},"identifier":"com.luckymarmot.BodyMultipartFormDataDynamicValue"}]</attribute>
<attribute name="order" type="int64">1</attribute>
<attribute name="order" type="int64">4</attribute>
<attribute name="name" type="string">connectworkspace</attribute>
<relationship name="parent" type="0/1" destination="LMREQUESTTREEITEM"></relationship>
<relationship name="children" type="0/0" destination="LMREQUESTTREEITEM"></relationship>
......@@ -98,17 +99,17 @@
<attribute name="order" type="int64">0</attribute>
<attribute name="name" type="string">Default Environments</attribute>
<relationship name="environments" type="0/0" destination="LMENVIRONMENT" idrefs="z106"></relationship>
<relationship name="variables" type="0/0" destination="LMENVIRONMENTVARIABLE" idrefs="z115 z114"></relationship>
<relationship name="variables" type="0/0" destination="LMENVIRONMENTVARIABLE" idrefs="z120 z114 z124 z128 z115"></relationship>
</object>
<object type="LMENVIRONMENT" id="z106">
<attribute name="uuid" type="string">692E45B1-9569-452F-A8F0-78D85095A654</attribute>
<attribute name="order" type="int64">0</attribute>
<attribute name="name" type="string">Vispa Local</attribute>
<relationship name="domain" type="0/1" destination="LMENVIRONMENTDOMAIN" idrefs="z105"></relationship>
<relationship name="variablesvalues" type="0/0" destination="LMENVIRONMENTVARIABLEVALUE" idrefs="z108 z107"></relationship>
<relationship name="variablesvalues" type="0/0" destination="LMENVIRONMENTVARIABLEVALUE" idrefs="z108 z122 z129 z123 z107"></relationship>
</object>
<object type="LMENVIRONMENTVARIABLEVALUE" id="z107">
<attribute name="value" type="string">http://localhost:4282/vispa</attribute>
<attribute name="value" type="string">http://localhost:4282</attribute>
<relationship name="environment" type="1/1" destination="LMENVIRONMENT" idrefs="z106"></relationship>
<relationship name="variable" type="1/1" destination="LMENVIRONMENTVARIABLE" idrefs="z115"></relationship>
</object>
......@@ -156,7 +157,7 @@
</object>
<object type="LMENVIRONMENTVARIABLE" id="z115">
<attribute name="uuid" type="string">0CE797C5-A148-4563-84AD-01058098CC63</attribute>
<attribute name="order" type="int64">0</attribute>
<attribute name="order" type="int64">1</attribute>
<attribute name="name" type="string">host</attribute>
<relationship name="domain" type="0/1" destination="LMENVIRONMENTDOMAIN" idrefs="z105"></relationship>
<relationship name="values" type="0/0" destination="LMENVIRONMENTVARIABLEVALUE" idrefs="z107"></relationship>
......@@ -166,38 +167,121 @@
<attribute name="order" type="int64">1</attribute>
<attribute name="name" type="string">Default Cookie Jar</attribute>
</object>
<object type="LMKEYVALUE" id="z117">
<attribute name="order" type="int64">1</attribute>
<object type="LMENVIRONMENTVARIABLE" id="z120">
<attribute name="uuid" type="string">10E33EB2-6E5C-42B0-BC8B-94758704580C</attribute>
<attribute name="order" type="int64">2</attribute>
<attribute name="name" type="string">username</attribute>
<relationship name="domain" type="0/1" destination="LMENVIRONMENTDOMAIN" idrefs="z105"></relationship>
<relationship name="values" type="0/0" destination="LMENVIRONMENTVARIABLEVALUE" idrefs="z123"></relationship>
</object>
<object type="LMKEYVALUE" id="z121">
<attribute name="value" type="string"></attribute>
<attribute name="order" type="int64">0</attribute>
<attribute name="name" type="string"></attribute>
<attribute name="enabled" type="bool">1</attribute>
<relationship name="groupforbodyparameters" type="0/1" destination="LMREQUESTGROUP"></relationship>
<relationship name="groupforheaders" type="0/1" destination="LMREQUESTGROUP"></relationship>
<relationship name="groupforurlparameters" type="0/1" destination="LMREQUESTGROUP"></relationship>
<relationship name="request" type="0/1" destination="LMREQUEST" idrefs="z118"></relationship>
<relationship name="request" type="0/1" destination="LMREQUEST" idrefs="z125"></relationship>
</object>
<object type="LMREQUEST" id="z118">
<attribute name="uuid" type="string">C691DCF6-3140-44F8-9FB2-F3956931B503</attribute>
<attribute name="url" type="string">[{"data":{"environmentVariable":"0CE797C5-A148-4563-84AD-01058098CC63"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"},"\\/extensions\\/test\\/foo\\/99"]</attribute>
<object type="LMENVIRONMENTVARIABLEVALUE" id="z122">
<attribute name="value" type="string">123123123</attribute>
<relationship name="environment" type="1/1" destination="LMENVIRONMENT" idrefs="z106"></relationship>
<relationship name="variable" type="1/1" destination="LMENVIRONMENTVARIABLE" idrefs="z124"></relationship>
</object>
<object type="LMENVIRONMENTVARIABLEVALUE" id="z123">
<attribute name="value" type="string">Marcel</attribute>
<relationship name="environment" type="1/1" destination="LMENVIRONMENT" idrefs="z106"></relationship>
<relationship name="variable" type="1/1" destination="LMENVIRONMENTVARIABLE" idrefs="z120"></relationship>
</object>
<object type="LMENVIRONMENTVARIABLE" id="z124">
<attribute name="uuid" type="string">B9C862C6-9E0B-4049-AC8F-76009A1CBF28</attribute>
<attribute name="order" type="int64">3</attribute>
<attribute name="name" type="string">password</attribute>
<relationship name="domain" type="0/1" destination="LMENVIRONMENTDOMAIN" idrefs="z105"></relationship>
<relationship name="values" type="0/0" destination="LMENVIRONMENTVARIABLEVALUE" idrefs="z122"></relationship>
</object>
<object type="LMREQUEST" id="z125">
<attribute name="body" type="string">[{"data":{"keyValues":[[["username"],[{"data":{"environmentVariable":"10E33EB2-6E5C-42B0-BC8B-94758704580C"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"}],true],[["email"],[{"data":{"environmentVariable":"AB479509-FB1C-4F82-8190-667A9CECEA0D"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"}],true]]},"identifier":"com.luckymarmot.BodyFormKeyValueDynamicValue"}]</attribute>
<attribute name="uuid" type="string">C122510F-ABB7-42C3-9752-6B7993014AD0</attribute>
<attribute name="url" type="string">[{"data":{"environmentVariable":"0CE797C5-A148-4563-84AD-01058098CC63"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"},"\\/ajax\\/register"]</attribute>
<attribute name="timeoutinterval" type="float">30</attribute>
<attribute name="storecookies" type="bool">1</attribute>
<attribute name="sendcookies" type="bool">1</attribute>
<attribute name="redirectmethod" type="bool">0</attribute>
<attribute name="redirectauthorization" type="bool">0</attribute>
<attribute name="method" type="string">GET</attribute>
<attribute name="method" type="string">POST</attribute>
<attribute name="followredirects" type="bool">0</attribute>
<attribute name="order" type="int64">2</attribute>
<attribute name="name" type="string">test</attribute>
<attribute name="name" type="string">register</attribute>
<relationship name="parent" type="0/1" destination="LMREQUESTTREEITEM"></relationship>
<relationship name="children" type="0/0" destination="LMREQUESTTREEITEM"></relationship>
<relationship name="headers" type="0/0" destination="LMKEYVALUE" idrefs="z117 z119"></relationship>
<relationship name="headers" type="0/0" destination="LMKEYVALUE" idrefs="z121"></relationship>
</object>
<object type="LMKEYVALUE" id="z119">
<attribute name="value" type="string">[{"data":{"environmentVariable":"3F9471A7-7867-4387-A4FC-AB431DE75BA9"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"}]</attribute>
<object type="LMREQUEST" id="z126">
<attribute name="uuid" type="string">5CAE6CF6-1305-4909-A234-91499453BC98</attribute>
<attribute name="url" type="string">[{"data":{"environmentVariable":"0CE797C5-A148-4563-84AD-01058098CC63"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"},"\\/logout"]</attribute>
<attribute name="timeoutinterval" type="float">30</attribute>
<attribute name="storecookies" type="bool">1</attribute>
<attribute name="sendcookies" type="bool">1</attribute>
<attribute name="redirectmethod" type="bool">0</attribute>
<attribute name="redirectauthorization" type="bool">0</attribute>
<attribute name="method" type="string">GET</attribute>
<attribute name="followredirects" type="bool">0</attribute>
<attribute name="body" type="string">[{"data":{"keyValues":[[["username"],[{"data":{"environmentVariable":"10E33EB2-6E5C-42B0-BC8B-94758704580C"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"}],true],[["password"],["Dfu7KuSr"],true]]},"identifier":"com.luckymarmot.BodyFormKeyValueDynamicValue"}]</attribute>
<attribute name="order" type="int64">0</attribute>
<attribute name="name" type="string">Cookie</attribute>
<attribute name="enabled" type="bool">0</attribute>
<attribute name="name" type="string">logout</attribute>
<relationship name="parent" type="0/1" destination="LMREQUESTTREEITEM"></relationship>
<relationship name="children" type="0/0" destination="LMREQUESTTREEITEM"></relationship>
<relationship name="headers" type="0/0" destination="LMKEYVALUE" idrefs="z127"></relationship>
</object>
<object type="LMKEYVALUE" id="z127">
<attribute name="value" type="string"></attribute>
<attribute name="order" type="int64">0</attribute>
<attribute name="name" type="string"></attribute>
<attribute name="enabled" type="bool">1</attribute>
<relationship name="groupforbodyparameters" type="0/1" destination="LMREQUESTGROUP"></relationship>
<relationship name="groupforheaders" type="0/1" destination="LMREQUESTGROUP"></relationship>
<relationship name="groupforurlparameters" type="0/1" destination="LMREQUESTGROUP"></relationship>
<relationship name="request" type="0/1" destination="LMREQUEST" idrefs="z118"></relationship>
<relationship name="request" type="0/1" destination="LMREQUEST" idrefs="z126"></relationship>
</object>
<object type="LMENVIRONMENTVARIABLE" id="z128">
<attribute name="uuid" type="string">AB479509-FB1C-4F82-8190-667A9CECEA0D</attribute>
<attribute name="order" type="int64">4</attribute>
<attribute name="name" type="string">email</attribute>
<relationship name="domain" type="0/1" destination="LMENVIRONMENTDOMAIN" idrefs="z105"></relationship>
<relationship name="values" type="0/0" destination="LMENVIRONMENTVARIABLEVALUE" idrefs="z129"></relationship>
</object>
<object type="LMENVIRONMENTVARIABLEVALUE" id="z129">
<attribute name="value" type="string">rieger@physik.rwth-aachen.de</attribute>
<relationship name="environment" type="1/1" destination="LMENVIRONMENT" idrefs="z106"></relationship>
<relationship name="variable" type="1/1" destination="LMENVIRONMENTVARIABLE" idrefs="z128"></relationship>
</object>
<object type="LMKEYVALUE" id="z130">
<attribute name="value" type="string"></attribute>
<attribute name="order" type="int64">0</attribute>
<attribute name="name" type="string"></attribute>
<attribute name="enabled" type="bool">1</attribute>
<relationship name="groupforbodyparameters" type="0/1" destination="LMREQUESTGROUP"></relationship>
<relationship name="groupforheaders" type="0/1" destination="LMREQUESTGROUP"></relationship>
<relationship name="groupforurlparameters" type="0/1" destination="LMREQUESTGROUP"></relationship>
<relationship name="request" type="0/1" destination="LMREQUEST" idrefs="z131"></relationship>
</object>
<object type="LMREQUEST" id="z131">
<attribute name="uuid" type="string">73599A9E-0DEC-4455-9BFB-B18FE2C5A7C8</attribute>
<attribute name="url" type="string">[{"data":{"environmentVariable":"0CE797C5-A148-4563-84AD-01058098CC63"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"},"\\/ajax\\/forgotpassword"]</attribute>
<attribute name="timeoutinterval" type="float">30</attribute>
<attribute name="storecookies" type="bool">1</attribute>
<attribute name="sendcookies" type="bool">1</attribute>
<attribute name="redirectmethod" type="bool">0</attribute>
<attribute name="redirectauthorization" type="bool">0</attribute>
<attribute name="method" type="string">POST</attribute>
<attribute name="followredirects" type="bool">0</attribute>
<attribute name="body" type="string">[{"data":{"keyValues":[[["username"],[{"data":{"environmentVariable":"10E33EB2-6E5C-42B0-BC8B-94758704580C"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"}],true]]},"identifier":"com.luckymarmot.BodyFormKeyValueDynamicValue"}]</attribute>
<attribute name="order" type="int64">3</attribute>
<attribute name="name" type="string">forgotpassword</attribute>
<relationship name="parent" type="0/1" destination="LMREQUESTTREEITEM"></relationship>
<relationship name="children" type="0/0" destination="LMREQUESTTREEITEM"></relationship>
<relationship name="headers" type="0/0" destination="LMKEYVALUE" idrefs="z130"></relationship>
</object>
</database>
\ No newline at end of file
......@@ -69,16 +69,17 @@ define([
return this;
}
$.post(this.url.dynamic("ajax/login"), {username: user, password: pass})
.done(function() {
$.post(this.url.dynamic("ajax/login"), {username: user, password: pass}).done(function(res) {
if (res.code != 200) {
$("#login-alert").fadeIn(100).render({alert: res.message});
$("#login-name").focus();
} else {
var d = new Date();
d.setTime(d.getTime() + 60e3);
$.cookie("tmpPass", pass, { expires: d });
window.location.href = self.url.dynamic(self.config.requestedPath);
}).fail(function(res) {
$("#login-alert").fadeIn(100).render({alert: res.responseJSON.message});
$("#login-name").focus();
});
}
});
return this;
},
......@@ -98,20 +99,21 @@ define([
return this;
}
$.post(this.url.dynamic("ajax/register"), {username: user, email: email})
.done(function(response) {
if (response.data.hash)
window.location.href = self.url.dynamic("password/" + response.data.hash);
else {
$.post(this.url.dynamic("ajax/register"), {username: user, email: email}).done(function(res) {
if (res.code != 200) {
$("#register-alert").fadeIn(100).render({alert: res.message});
$("#register-name").focus();
} else {
if (res.data.hash) {
window.location.href = self.url.dynamic("password/" + res.data.hash);
} else {
$("#register-success").fadeIn(100);
setTimeout(function() {
window.location.href = self.url.dynamic("/");
}, 4000);
}
}).fail(function(res) {
$("#register-alert").fadeIn(100).render({alert: res.responseJSON.message});
$("#register-name").focus();
});
}
});
return this;
},
......@@ -129,16 +131,17 @@ define([
return this;
}
$.post(this.url.dynamic("ajax/forgotpassword"), {username: user})
.done(function(response) {
$.post(this.url.dynamic("ajax/forgotpassword"), {username: user}).done(function(res) {
if (res.code != 200) {
$("#forgot-alert").fadeIn(100).render({alert: res.message});
$("#forgot-name").focus();
} else {
$("#forgot-success").fadeIn(100);
setTimeout(function() {
window.location.href = self.url.dynamic("/");
}, 4000);
}).fail(function(res) {
$("#forgot-alert").fadeIn(100).render({alert: res.responseJSON.message});
$("#forgot-name").focus();
});
}
});
return this;
}
......
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