Showing
19 changed files
with
429 additions
and
50 deletions
... | ... | @@ -24,6 +24,7 @@ nobase_trdata_DATA = assets/html/example.html \ |
24 | 24 | assets/html/layout.html \ |
25 | 25 | assets/html/_documentation.html \ |
26 | 26 | assets/html/_download.html \ |
27 | + assets/html/_myaccount.html \ | |
27 | 28 | assets/image/waldschrat.jpg \ |
28 | 29 | assets/image/fav128.png \ |
29 | 30 | assets/image/fav16.png \ | ... | ... |
... | ... | @@ -5,6 +5,7 @@ |
5 | 5 | <li><a href="/download.html">download</a></li> |
6 | 6 | <li class="signup"><span>signup</span></li> |
7 | 7 | <li class="login"><span>login</span></li> |
8 | + <li class="my_account hide"><span>my account</span></li> | |
8 | 9 | <li class="logout hide"><span>logout</span></li> |
9 | 10 | <li class="menuedge"></li> |
10 | 11 | <div></div> | ... | ... |
assets/html/_myaccount.html
0 → 100644
1 | +<h4>My account</h4><div id="myaccount-close" class="link right">(close)</div> | |
2 | +<hr /> | |
3 | +<form> | |
4 | + <div class="firstname"> | |
5 | + <label for="firstname">firstname</label> | |
6 | + <input type="text" name="firstname" /><br /> | |
7 | + </div> | |
8 | + <div class="surname"> | |
9 | + <label for="surname">surname</label> | |
10 | + <input type="text" name="surname" /><br /> | |
11 | + </div> | |
12 | + <div class="email"> | |
13 | + <label for="mail">email</label> | |
14 | + <input type="text" name="email" /><br /> | |
15 | + </div> | |
16 | + <div style="height: 10px;" /> | |
17 | + <div> | |
18 | + <hr /> | |
19 | + <hr /> | |
20 | + </div> | |
21 | + <div style="height: 10px;" /> | |
22 | + <div> | |
23 | + <input type="submit" value="update account" /> | |
24 | + </div> | |
25 | +</form> | |
26 | + | |
27 | +<!-- vim: set ts=4 sw=4: --> | ... | ... |
... | ... | @@ -63,6 +63,27 @@ |
63 | 63 | </table> |
64 | 64 | </div> |
65 | 65 | |
66 | + <div id="myaccount-container" class="ui-widget-content border hide"> | |
67 | + <table> | |
68 | + <tr> | |
69 | + <td class="tl"></td> | |
70 | + <td class="t"></td> | |
71 | + <td class="tr"></td> | |
72 | + </tr> | |
73 | + <td class="l"></td> | |
74 | + <td id ="myaccount"> | |
75 | + </td> | |
76 | + <td class="r"></td> | |
77 | + <tr> | |
78 | + </tr> | |
79 | + <tr> | |
80 | + <td class="bl"></td> | |
81 | + <td class="b"></td> | |
82 | + <td class="br"></td> | |
83 | + </tr> | |
84 | + </table> | |
85 | + </div> | |
86 | + | |
66 | 87 | <div id="page"> |
67 | 88 | <div id="statusline"> |
68 | 89 | </div> | ... | ... |
... | ... | @@ -25,20 +25,24 @@ Application.prototype.logout = function() { |
25 | 25 | } |
26 | 26 | |
27 | 27 | Application.prototype.login = function(ev) { |
28 | - this._sendForm("#login", "/authenticate/", ev); | |
28 | + this._sendForm("#login", "/authenticate/", "POST", ev); | |
29 | 29 | } |
30 | 30 | |
31 | 31 | Application.prototype.signup = function(ev) { |
32 | - this._sendForm("#signup", "/signup/", ev); | |
32 | + this._sendForm("#signup", "/signup/", "POST", ev); | |
33 | +} | |
34 | + | |
35 | +Application.prototype.userupdate = function(ev) { | |
36 | + this._sendForm("#myaccount", "/user/", "PUT", ev); | |
33 | 37 | } |
34 | 38 | |
35 | 39 | |
36 | -Application.prototype._sendForm = function(id, url, ev) { | |
40 | +Application.prototype._sendForm = function(id, url, method, ev) { | |
37 | 41 | ev.preventDefault(); |
38 | 42 | $.ajax({ |
39 | 43 | dataType : "json", |
40 | 44 | url : url, |
41 | - type : "POST", | |
45 | + type : method, | |
42 | 46 | data : $(id + " form").serialize(), |
43 | 47 | success : $.proxy(this._formSuccess, this, id), |
44 | 48 | complete : $.proxy(this.session.update, this.session) | ... | ... |
... | ... | @@ -55,6 +55,19 @@ $(document).ready(function() { |
55 | 55 | $("#signup form").submit($.proxy(application.signup, application)); |
56 | 56 | }); |
57 | 57 | |
58 | + $("#myaccount").load("/_myaccount.html", function (){ | |
59 | + $(function() { | |
60 | + $("#myaccount-container").draggable(); | |
61 | + }); | |
62 | + | |
63 | + $("#myaccount-close").click(function (e) { | |
64 | + $("#myaccount-container").addClass("hide"); | |
65 | + }); | |
66 | + | |
67 | + $("#myaccount form").submit( | |
68 | + $.proxy(application.userupdate, application)); | |
69 | + }); | |
70 | + | |
58 | 71 | $("#footer").load("/_footer.html", function (){ |
59 | 72 | $.getJSON( |
60 | 73 | "/loc/", | ... | ... |
1 | -function Menu(menuSelector, application, user) | |
1 | +function Menu(menuSelector, application) | |
2 | 2 | { |
3 | - this.application = application; | |
3 | + this.application = application; | |
4 | 4 | |
5 | - this.signupSelector = menuSelector + " ul li.signup"; | |
6 | - this.loginSelector = menuSelector + " ul li.login"; | |
7 | - this.logoutSelector = menuSelector + " ul li.logout"; | |
5 | + this.signupSelector = menuSelector + " ul li.signup"; | |
6 | + this.loginSelector = menuSelector + " ul li.login"; | |
7 | + this.logoutSelector = menuSelector + " ul li.logout"; | |
8 | + this.myaccountSelector = menuSelector + " ul li.my_account"; | |
8 | 9 | |
9 | 10 | this.menuElement = $(menuSelector); |
10 | 11 | } |
... | ... | @@ -14,14 +15,20 @@ Menu.prototype.init = function() { |
14 | 15 | } |
15 | 16 | |
16 | 17 | Menu.prototype.update = function() { |
18 | + $("#myaccount div.firstname input").val(this.application.user.firstname); | |
19 | + $("#myaccount div.surname input").val(this.application.user.surname); | |
20 | + $("#myaccount div.email input").val(this.application.user.email); | |
21 | + | |
17 | 22 | if (this.application.user.isEmpty()) { |
18 | 23 | $(this.signupSelector).removeClass("hide"); |
19 | 24 | $(this.loginSelector).removeClass("hide"); |
20 | 25 | $(this.logoutSelector).addClass("hide"); |
26 | + $(this.myaccountSelector).addClass("hide"); | |
21 | 27 | } else { |
22 | 28 | $(this.signupSelector).addClass("hide"); |
23 | 29 | $(this.loginSelector).addClass("hide"); |
24 | 30 | $(this.logoutSelector).removeClass("hide"); |
31 | + $(this.myaccountSelector).removeClass("hide"); | |
25 | 32 | } |
26 | 33 | } |
27 | 34 | |
... | ... | @@ -51,6 +58,17 @@ Menu.prototype._menuActions = function() { |
51 | 58 | |
52 | 59 | $(this.logoutSelector) |
53 | 60 | .click($.proxy(this.application.logout, this.application)); |
61 | + | |
62 | + $(this.myaccountSelector).click(function(ev) { | |
63 | + if ($("#myaccount-container").hasClass("hide")) { | |
64 | + $("#myaccount-container").css("top", ev.pageY + 20); | |
65 | + $("#myaccount-container").css("left", ev.pageX - 100); | |
66 | + $("#myaccount-container").removeClass("hide"); | |
67 | + } else { | |
68 | + $("#myaccount-container").addClass("hide"); | |
69 | + } | |
70 | + }); | |
71 | + | |
54 | 72 | } |
55 | 73 | |
56 | 74 | // vim: set ts=4 sw=4: | ... | ... |
... | ... | @@ -12,6 +12,17 @@ div#randval { |
12 | 12 | z-index: 20; |
13 | 13 | } |
14 | 14 | |
15 | +div#myaccount-container { | |
16 | + -moz-box-shadow: 0 4px 8px rgba(0,0,0,0.5); | |
17 | + -webkit-box-shadow: 0 4px 8px rgba(0,0,0,0.5); | |
18 | + box-shadow: 0 4px 8px rgba(0,0,0,0.5); | |
19 | + padding: 0px; | |
20 | + position: fixed; | |
21 | + background-image: url(/image/rambler-bg.jpg); | |
22 | + border-radius: 5px; | |
23 | + z-index: 20; | |
24 | +} | |
25 | + | |
15 | 26 | div#signup-container { |
16 | 27 | -moz-box-shadow: 0 4px 8px rgba(0,0,0,0.5); |
17 | 28 | -webkit-box-shadow: 0 4px 8px rgba(0,0,0,0.5); | ... | ... |
... | ... | @@ -261,7 +261,7 @@ div.border .br { |
261 | 261 | vertical-align: center; |
262 | 262 | } |
263 | 263 | |
264 | -#login label, #signup label { | |
264 | +#login label, #signup label, #myaccount label { | |
265 | 265 | font-family: old_newspaper; |
266 | 266 | font-size: 15px; |
267 | 267 | font-weight: bold; |
... | ... | @@ -269,19 +269,19 @@ div.border .br { |
269 | 269 | display: table-cell; |
270 | 270 | } |
271 | 271 | |
272 | -#login input, #signup input { | |
272 | +#login input, #signup input, #myaccount input { | |
273 | 273 | display: table-cell; |
274 | 274 | } |
275 | 275 | |
276 | -#login div, #signup div { | |
276 | +#login div, #signup div, #myaccount div { | |
277 | 277 | display: table-row; |
278 | 278 | } |
279 | 279 | |
280 | -#login form, #signup form { | |
280 | +#login form, #signup form, #myaccount form { | |
281 | 281 | display: table; |
282 | 282 | } |
283 | 283 | |
284 | -#login form hr, #signup form hr { | |
284 | +#login form hr, #signup form hr, #myaccount form hr { | |
285 | 285 | display: table-cell; |
286 | 286 | } |
287 | 287 | ... | ... |
... | ... | @@ -66,6 +66,7 @@ CLASS(Application) { |
66 | 66 | int applicationLogin(Application, Credential, Session); |
67 | 67 | void applicationLogout(Application, Session); |
68 | 68 | Uuid applicationCreateUser(Application, Credential, User); |
69 | +Uuid applicationUpdateUser(Application, User); | |
69 | 70 | User applicationGetUser(Application, Uuid); |
70 | 71 | int applicationUpdatePassword(Application, Credential, User); |
71 | 72 | ... | ... |
... | ... | @@ -6,6 +6,7 @@ APPLICATION = application.c \ |
6 | 6 | logout.c \ |
7 | 7 | get_user.c \ |
8 | 8 | create_user.c \ |
9 | + update_user.c \ | |
9 | 10 | update_password.c \ |
10 | 11 | session_start.c \ |
11 | 12 | session_stop.c \ |
... | ... | @@ -21,12 +22,16 @@ CONTROLLER = controller/authenticate/create.c \ |
21 | 22 | controller/randval/read.c \ |
22 | 23 | controller/sessinfo/read.c \ |
23 | 24 | controller/user/create.c \ |
25 | + controller/user/update.c \ | |
24 | 26 | controller/user/read.c \ |
25 | 27 | controller/signup/create.c \ |
26 | 28 | controller/version/read.c \ |
27 | 29 | controller/loc/read.c \ |
28 | 30 | controller/_validate_password_repeat.c \ |
29 | - controller/_process_user_create_args.c | |
31 | + controller/_process_user_create_args.c \ | |
32 | + controller/_get_user_from_args.c \ | |
33 | + controller/_update_user_from_args.c \ | |
34 | + controller/_get_credential_from_args.c | |
30 | 35 | |
31 | 36 | AM_CFLAGS += -I../../include/ |
32 | 37 | ... | ... |
1 | +/** | |
2 | + * \file | |
3 | + * | |
4 | + * \author Georg Hopp | |
5 | + * | |
6 | + * \copyright | |
7 | + * Copyright © 2013 Georg Hopp | |
8 | + * | |
9 | + * This program is free software: you can redistribute it and/or modify | |
10 | + * it under the terms of the GNU General Public License as published by | |
11 | + * the Free Software Foundation, either version 3 of the License, or | |
12 | + * (at your option) any later version. | |
13 | + * | |
14 | + * This program is distributed in the hope that it will be useful, | |
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | + * GNU General Public License for more details. | |
18 | + * | |
19 | + * You should have received a copy of the GNU General Public License | |
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + */ | |
22 | + | |
23 | +#define _GNU_SOURCE | |
24 | + | |
25 | +#include "hash.h" | |
26 | +#include "auth/credential.h" | |
27 | + | |
28 | +#include "utils/memory.h" | |
29 | +#include "commons.h" | |
30 | + | |
31 | +int _controllerValidatePasswordRepeat(char *, size_t, char *, size_t); | |
32 | + | |
33 | +Credential | |
34 | +_controllerGetCredentialFromArgs(Hash args) | |
35 | +{ | |
36 | + HashValue email = hashGet(args, CSTRA("email")); | |
37 | + HashValue password = hashGet(args, CSTRA("password")); | |
38 | + HashValue pwrepeat = hashGet(args, CSTRA("pwrepeat")); | |
39 | + | |
40 | + if ( | |
41 | + NULL == email || | |
42 | + NULL == password || | |
43 | + NULL == pwrepeat) | |
44 | + { | |
45 | + return FALSE; | |
46 | + } | |
47 | + | |
48 | + if (! _controllerValidatePasswordRepeat( | |
49 | + password->value, | |
50 | + password->nvalue, | |
51 | + pwrepeat->value, | |
52 | + pwrepeat->nvalue)) | |
53 | + { | |
54 | + return FALSE; | |
55 | + } | |
56 | + | |
57 | + return new(Credential, | |
58 | + CRED_PASSWORD, | |
59 | + (char *)(email->value), email->nvalue, | |
60 | + (char *)(password->value), password->nvalue); | |
61 | +} | |
62 | + | |
63 | +// vim: set ts=4 sw=4: | ... | ... |
1 | +/** | |
2 | + * \file | |
3 | + * | |
4 | + * \author Georg Hopp | |
5 | + * | |
6 | + * \copyright | |
7 | + * Copyright © 2013 Georg Hopp | |
8 | + * | |
9 | + * This program is free software: you can redistribute it and/or modify | |
10 | + * it under the terms of the GNU General Public License as published by | |
11 | + * the Free Software Foundation, either version 3 of the License, or | |
12 | + * (at your option) any later version. | |
13 | + * | |
14 | + * This program is distributed in the hope that it will be useful, | |
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | + * GNU General Public License for more details. | |
18 | + * | |
19 | + * You should have received a copy of the GNU General Public License | |
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + */ | |
22 | + | |
23 | +#define _GNU_SOURCE | |
24 | + | |
25 | +#include "hash.h" | |
26 | +#include "user.h" | |
27 | + | |
28 | +#include "utils/memory.h" | |
29 | +#include "commons.h" | |
30 | + | |
31 | + | |
32 | +User | |
33 | +_controllerGetUserFromArgs(Hash args) | |
34 | +{ | |
35 | + HashValue email = hashGet(args, CSTRA("email")); | |
36 | + HashValue firstname = hashGet(args, CSTRA("firstname")); | |
37 | + HashValue surname = hashGet(args, CSTRA("surname")); | |
38 | + | |
39 | + if ( | |
40 | + NULL == email || | |
41 | + NULL == firstname || | |
42 | + NULL == surname) | |
43 | + { | |
44 | + return FALSE; | |
45 | + } | |
46 | + | |
47 | + return new(User, | |
48 | + (char *)(email->value), email->nvalue, | |
49 | + (char *)(email->value), email->nvalue, | |
50 | + (char *)(firstname->value), firstname->nvalue, | |
51 | + (char *)(surname->value), surname->nvalue); | |
52 | +} | |
53 | + | |
54 | +// vim: set ts=4 sw=4: | ... | ... |
... | ... | @@ -29,48 +29,22 @@ |
29 | 29 | #include "utils/memory.h" |
30 | 30 | #include "commons.h" |
31 | 31 | |
32 | -int _controllerValidatePasswordRepeat(char *, size_t, char *, size_t); | |
33 | - | |
32 | +User _controllerGetUserFromArgs(Hash args); | |
33 | +Credential _controllerGetCredentialFromArgs(Hash args); | |
34 | 34 | |
35 | 35 | int |
36 | 36 | _controllerProcessUserCreateArgs(Hash args, User * user, Credential * cred) |
37 | 37 | { |
38 | - HashValue email = hashGet(args, CSTRA("email")); | |
39 | - HashValue password = hashGet(args, CSTRA("password")); | |
40 | - HashValue pwrepeat = hashGet(args, CSTRA("pwrepeat")); | |
41 | - HashValue firstname = hashGet(args, CSTRA("firstname")); | |
42 | - HashValue surname = hashGet(args, CSTRA("surname")); | |
43 | - | |
44 | - if ( | |
45 | - NULL == email || | |
46 | - NULL == password || | |
47 | - NULL == pwrepeat || | |
48 | - NULL == firstname || | |
49 | - NULL == surname) | |
50 | - { | |
51 | - return FALSE; | |
52 | - } | |
38 | + *user = _controllerGetUserFromArgs(args); | |
39 | + *cred = _controllerGetCredentialFromArgs(args); | |
40 | + | |
41 | + if (NULL == *user || NULL == *cred) { | |
42 | + delete(*user); | |
43 | + delete(*cred); | |
53 | 44 | |
54 | - if (! _controllerValidatePasswordRepeat( | |
55 | - password->value, | |
56 | - password->nvalue, | |
57 | - pwrepeat->value, | |
58 | - pwrepeat->nvalue)) | |
59 | - { | |
60 | 45 | return FALSE; |
61 | 46 | } |
62 | 47 | |
63 | - *cred = new(Credential, | |
64 | - CRED_PASSWORD, | |
65 | - (char *)(email->value), email->nvalue, | |
66 | - (char *)(password->value), password->nvalue); | |
67 | - | |
68 | - *user = new(User, | |
69 | - (char *)(email->value), email->nvalue, | |
70 | - (char *)(email->value), email->nvalue, | |
71 | - (char *)(firstname->value), firstname->nvalue, | |
72 | - (char *)(surname->value), surname->nvalue); | |
73 | - | |
74 | 48 | return TRUE; |
75 | 49 | } |
76 | 50 | ... | ... |
1 | +/** | |
2 | + * \file | |
3 | + * | |
4 | + * \author Georg Hopp | |
5 | + * | |
6 | + * \copyright | |
7 | + * Copyright © 2013 Georg Hopp | |
8 | + * | |
9 | + * This program is free software: you can redistribute it and/or modify | |
10 | + * it under the terms of the GNU General Public License as published by | |
11 | + * the Free Software Foundation, either version 3 of the License, or | |
12 | + * (at your option) any later version. | |
13 | + * | |
14 | + * This program is distributed in the hope that it will be useful, | |
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | + * GNU General Public License for more details. | |
18 | + * | |
19 | + * You should have received a copy of the GNU General Public License | |
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + */ | |
22 | + | |
23 | +#define _GNU_SOURCE | |
24 | + | |
25 | +#include "hash.h" | |
26 | +#include "user.h" | |
27 | + | |
28 | +#include "utils/memory.h" | |
29 | +#include "commons.h" | |
30 | + | |
31 | + | |
32 | +int | |
33 | +_controllerUpdateUserFromArgs(Hash args, User * user) | |
34 | +{ | |
35 | + HashValue email = hashGet(args, CSTRA("email")); | |
36 | + HashValue firstname = hashGet(args, CSTRA("firstname")); | |
37 | + HashValue surname = hashGet(args, CSTRA("surname")); | |
38 | + User new_user; | |
39 | + | |
40 | + if ( | |
41 | + NULL == email || | |
42 | + NULL == firstname || | |
43 | + NULL == surname) | |
44 | + { | |
45 | + return FALSE; | |
46 | + } | |
47 | + | |
48 | + new_user = new(User, | |
49 | + (char *)((*user)->username), *(*user)->nusername, | |
50 | + (char *)(email->value), email->nvalue, | |
51 | + (char *)(firstname->value), firstname->nvalue, | |
52 | + (char *)(surname->value), surname->nvalue); | |
53 | + | |
54 | + delete(*user); | |
55 | + *user = new_user; | |
56 | + | |
57 | + return TRUE; | |
58 | +} | |
59 | + | |
60 | +// vim: set ts=4 sw=4: | ... | ... |
src/application/controller/user/update.c
0 → 100644
1 | +/** | |
2 | + * \file | |
3 | + * | |
4 | + * \author Georg Hopp | |
5 | + * | |
6 | + * \copyright | |
7 | + * Copyright © 2013 Georg Hopp | |
8 | + * | |
9 | + * This program is free software: you can redistribute it and/or modify | |
10 | + * it under the terms of the GNU General Public License as published by | |
11 | + * the Free Software Foundation, either version 3 of the License, or | |
12 | + * (at your option) any later version. | |
13 | + * | |
14 | + * This program is distributed in the hope that it will be useful, | |
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | + * GNU General Public License for more details. | |
18 | + * | |
19 | + * You should have received a copy of the GNU General Public License | |
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + */ | |
22 | + | |
23 | +#define _GNU_SOURCE | |
24 | + | |
25 | +#include "application/application.h" | |
26 | +#include "session.h" | |
27 | +#include "hash.h" | |
28 | +#include "user.h" | |
29 | + | |
30 | +#include "utils/memory.h" | |
31 | +#include "commons.h" | |
32 | + | |
33 | +char * controllerCurrentuserRead(Application, Session, Hash); | |
34 | +int _controllerUpdateUserFromArgs(Hash, User *); | |
35 | + | |
36 | +char * | |
37 | +controllerUserUpdate( | |
38 | + Application application, | |
39 | + Session session, | |
40 | + Hash args) | |
41 | +{ | |
42 | + if (! _controllerUpdateUserFromArgs(args, &(session->user))) { | |
43 | + return NULL; | |
44 | + } | |
45 | + | |
46 | + if (0 == uuidCompare( | |
47 | + uuidZero, | |
48 | + applicationUpdateUser(application, session->user))) | |
49 | + { | |
50 | + return NULL; | |
51 | + } | |
52 | + | |
53 | + return controllerCurrentuserRead(application, session, NULL); | |
54 | +} | |
55 | + | |
56 | +// vim: set ts=4 sw=4: | ... | ... |
src/application/update_user.c
0 → 100644
1 | +/** | |
2 | + * \file | |
3 | + * | |
4 | + * \author Georg Hopp | |
5 | + * | |
6 | + * \copyright | |
7 | + * Copyright © 2013 Georg Hopp | |
8 | + * | |
9 | + * This program is free software: you can redistribute it and/or modify | |
10 | + * it under the terms of the GNU General Public License as published by | |
11 | + * the Free Software Foundation, either version 3 of the License, or | |
12 | + * (at your option) any later version. | |
13 | + * | |
14 | + * This program is distributed in the hope that it will be useful, | |
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | + * GNU General Public License for more details. | |
18 | + * | |
19 | + * You should have received a copy of the GNU General Public License | |
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + */ | |
22 | + | |
23 | +#define _GNU_SOURCE | |
24 | + | |
25 | +#include <stdio.h> | |
26 | +#include <stdlib.h> | |
27 | +#include <sys/types.h> | |
28 | + | |
29 | +#include "class.h" | |
30 | +#include "auth.h" | |
31 | +#include "user.h" | |
32 | +#include "uuid.h" | |
33 | +#include "storage/storage.h" | |
34 | +#include "application/application.h" | |
35 | + | |
36 | +#include "interface/serializable.h" | |
37 | +#include "interface/indexable.h" | |
38 | + | |
39 | +#include "utils/memory.h" | |
40 | +#include "commons.h" | |
41 | + | |
42 | +Uuid | |
43 | +applicationUpdateUser( | |
44 | + Application this, | |
45 | + User user) | |
46 | +{ | |
47 | + char * user_serialized; | |
48 | + size_t nuser_serialized; | |
49 | + Uuid index; | |
50 | + | |
51 | + index = indexUuid(user, this->user_namespace); | |
52 | + serialize(user, (unsigned char **)&user_serialized, &nuser_serialized); | |
53 | + | |
54 | + if (SPR_OK != storageUpdate( | |
55 | + this->users, | |
56 | + (char *)(index->uuid).value, | |
57 | + sizeof((index->uuid).value), | |
58 | + user_serialized, | |
59 | + nuser_serialized)) | |
60 | + { | |
61 | + return uuidZero; | |
62 | + } | |
63 | + | |
64 | + return index; | |
65 | +} | |
66 | + | |
67 | +// vim: set ts=4 sw=4: | ... | ... |
... | ... | @@ -77,7 +77,9 @@ httpWorkerProcess(HttpWorker this, Stream st) |
77 | 77 | subjectNotify(this); |
78 | 78 | |
79 | 79 | if (NULL == this->current_response) { |
80 | - if (0 == strcmp("POST", this->current_request->method)) { | |
80 | + if (0 == strcmp("POST", this->current_request->method) || | |
81 | + 0 == strcmp("PUT", this->current_request->method)) | |
82 | + { | |
81 | 83 | /* |
82 | 84 | * we can't do post requests on our own... |
83 | 85 | */ | ... | ... |
Please
register
or
login
to post a comment